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 19 import java.nio.charset.Charset; 20 import java.nio.charset.StandardCharsets; 21 22 import org.apache.commons.geometry.io.core.GeometryFormat; 23 import org.apache.commons.geometry.io.core.input.GeometryInput; 24 import org.apache.commons.geometry.io.core.internal.GeometryIOUtils; 25 import org.apache.commons.geometry.io.euclidean.threed.AbstractBoundaryReadHandler3D; 26 import org.apache.commons.geometry.io.euclidean.threed.FacetDefinitionReader; 27 import org.apache.commons.geometry.io.euclidean.threed.GeometryFormat3D; 28 29 /** {@link org.apache.commons.geometry.io.euclidean.threed.BoundaryReadHandler3D BoundaryReadHandler3D} 30 * implementation for the non-standard {@link GeometryFormat3D#TXT TXT}. 31 * @see TextFacetDefinitionReader 32 */ 33 public class TextBoundaryReadHandler3D extends AbstractBoundaryReadHandler3D { 34 35 /** Default charset for reading text input. */ 36 private Charset defaultCharset = StandardCharsets.UTF_8; 37 38 /** Get the text input default charset, used if the input does not 39 * specify a charset. 40 * @return text input default charset 41 */ 42 public Charset getDefaultCharset() { 43 return defaultCharset; 44 } 45 46 /** Set the text input default charset, used if the input does not 47 * specify a charset. 48 * @param defaultCharset text input default charset 49 */ 50 public void setDefaultCharset(final Charset defaultCharset) { 51 this.defaultCharset = defaultCharset; 52 } 53 54 /** {@inheritDoc} */ 55 @Override 56 public GeometryFormat getFormat() { 57 return GeometryFormat3D.TXT; 58 } 59 60 /** {@inheritDoc} */ 61 @Override 62 public FacetDefinitionReader facetDefinitionReader(final GeometryInput in) { 63 return new TextFacetDefinitionReader(GeometryIOUtils.createBufferedReader(in, defaultCharset)); 64 } 65 }