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.configuration2.io; 018 019import java.io.IOException; 020import java.io.InputStream; 021 022import org.apache.commons.configuration2.ex.ConfigurationException; 023 024/** 025 * <p> 026 * Definition of an interface to be implemented by objects which support reading 027 * from an input stream. 028 * </p> 029 * <p> 030 * When reading data using a {@link FileHandler} per default a reader is used as 031 * defined by the {@link FileBased#read(java.io.Reader)} method. For some 032 * configuration formats it is necessary to directly read binary data. In order 033 * to achieve this, a {@link FileBased} object can also implement this 034 * interface. It defines an additional {@code read()} method expecting an 035 * {@code InputStream} as argument. If the {@code FileHandler} detects that its 036 * associated {@code FileBased} object implements this interface, it passes the 037 * input stream directly rather than transforming it to a reader. 038 * </p> 039 * 040 * @since 2.0 041 */ 042public interface InputStreamSupport 043{ 044 /** 045 * Reads the content of this object from the specified {@code InputStream}. 046 * 047 * @param in the input stream 048 * @throws ConfigurationException if a non-I/O related problem occurs, e.g. 049 * the data read does not have the expected format 050 * @throws IOException if an I/O error occurs 051 */ 052 void read(InputStream in) throws ConfigurationException, IOException; 053}