Source code
Description: source: package: org.apache.commons.configuration2.io, interface: InputStreamSupport

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