001package org.unix4j.io;
002
003import org.unix4j.line.Line;
004
005import java.util.Iterator;
006
007/**
008 * Represents a line-by-line input device.
009 */
010public interface Input extends Iterable<Line>, AutoCloseable {
011        /**
012         * Returns true if there are more lines to be read.
013         * 
014         * @return true if more lines exist
015         */
016        boolean hasMoreLines();
017
018        /**
019         * Reads the next line. Returns null if no next line exists.
020         * 
021         * @return the next line, or null if no next line exists.
022         */
023        Line readLine();
024
025        /**
026         * Returns an immutable iterator over all lines returned by this input
027         * object.
028         * 
029         * @return an immutable line iterator
030         */
031        @Override
032        Iterator<Line> iterator();
033
034        /**
035         * Close underlying resources if any, as for instance the source file.
036         */
037        @Override
038        void close();
039}