001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.geometry.io.core; 018 019import java.nio.charset.Charset; 020 021/** Abstract base class for {@link GeometryIOMetadata} implementations. 022 */ 023public class AbstractGeometryIOMetadata implements GeometryIOMetadata { 024 025 /** File name; may be null. */ 026 private final String fileName; 027 028 /** Charset; may be null. */ 029 private final Charset charset; 030 031 /** Construct a new instance with the given file name and charset. 032 * @param fileName file name; may be null 033 * @param charset charset; may be null 034 */ 035 protected AbstractGeometryIOMetadata(final String fileName, final Charset charset) { 036 this.fileName = fileName; 037 this.charset = charset; 038 } 039 040 /** {@inheritDoc} */ 041 @Override 042 public String getFileName() { 043 return fileName; 044 } 045 046 /** {@inheritDoc} */ 047 @Override 048 public Charset getCharset() { 049 return charset; 050 } 051 052 /** {@inheritDoc} */ 053 @Override 054 public String toString() { 055 final StringBuilder sb = new StringBuilder(); 056 sb.append(getClass().getSimpleName()) 057 .append("[fileName= ") 058 .append(getFileName()) 059 .append(']'); 060 061 return sb.toString(); 062 } 063}