TextBoundaryReadHandler3D.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.apache.commons.geometry.io.euclidean.threed.txt;

  18. import java.nio.charset.Charset;
  19. import java.nio.charset.StandardCharsets;

  20. import org.apache.commons.geometry.io.core.GeometryFormat;
  21. import org.apache.commons.geometry.io.core.input.GeometryInput;
  22. import org.apache.commons.geometry.io.core.internal.GeometryIOUtils;
  23. import org.apache.commons.geometry.io.euclidean.threed.AbstractBoundaryReadHandler3D;
  24. import org.apache.commons.geometry.io.euclidean.threed.FacetDefinitionReader;
  25. import org.apache.commons.geometry.io.euclidean.threed.GeometryFormat3D;

  26. /** {@link org.apache.commons.geometry.io.euclidean.threed.BoundaryReadHandler3D BoundaryReadHandler3D}
  27.  * implementation for the non-standard {@link GeometryFormat3D#TXT TXT}.
  28.  * @see TextFacetDefinitionReader
  29.  */
  30. public class TextBoundaryReadHandler3D extends AbstractBoundaryReadHandler3D {

  31.     /** Default charset for reading text input. */
  32.     private Charset defaultCharset = StandardCharsets.UTF_8;

  33.     /** Get the text input default charset, used if the input does not
  34.      * specify a charset.
  35.      * @return text input default charset
  36.      */
  37.     public Charset getDefaultCharset() {
  38.         return defaultCharset;
  39.     }

  40.     /** Set the text input default charset, used if the input does not
  41.      * specify a charset.
  42.      * @param defaultCharset text input default charset
  43.      */
  44.     public void setDefaultCharset(final Charset defaultCharset) {
  45.         this.defaultCharset = defaultCharset;
  46.     }

  47.     /** {@inheritDoc} */
  48.     @Override
  49.     public GeometryFormat getFormat() {
  50.         return GeometryFormat3D.TXT;
  51.     }

  52.     /** {@inheritDoc} */
  53.     @Override
  54.     public FacetDefinitionReader facetDefinitionReader(final GeometryInput in) {
  55.         return new TextFacetDefinitionReader(GeometryIOUtils.createBufferedReader(in, defaultCharset));
  56.     }
  57. }