///+INCOMPLETE //============================================================================== // tribble/io/LineInputStream.java //------------------------------------------------------------------------------ package tribble.io; // System imports import java.io.IOException; import java.io.Reader; import java.lang.String; // Local imports import tribble.io.LineInputStreamI; import tribble.io.TextLineI; /******************************************************************************* * Generic text line input stream interface. * *
* This is a default implementation of the {@link LineInputStreamI} interface.
*
* @version $Revision: 1.1 $ $Date: 2001/04/23 18:19:38 $
* @since 2001-04-23
* @author
* David R. Tribble,
* david@tribble.com.
*
* Copyright ©2001 by David R. Tribble,
* all rights reserved.
*
* Permission is granted to freely use and distribute this source code
* provided that the original copyright and authorship notices remain
* intact.
*
* @see CharInputStreamI
* @see TextLine
*/
public class LineInputStream
implements LineInputStreamI
{
// Identification
/** Revision information. */
static final String REV =
"@(#)tribble/io/LineInputStream.java $Revision: 1.1 $ $Date: 2001/04/23 18:19:38 $\n";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Protected variables
/** Input stream. */
protected Reader m_in;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Public constructor methods
/***************************************************************************
* Constructor.
*
* @since 1.1, 2001-04-23
*/
public LineInputStream()
{
// Do nothing
}
/***************************************************************************
* Constructor.
* Establishes the input stream from which to read text lines.
*
* @param in
* The input stream from which to read text lines.
*
* @since 1.1, 2001-04-23
*/
public LineInputStream(Reader in)
{
// Establish a new input stream
setInput(in);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Public methods
/***************************************************************************
* Establishes the input stream from which to read text lines.
*
* @param in
* The input stream from which to read text lines.
*
* @since 1.1, 2001-04-23
*/
public void setInput(Reader in)
{
// Establish a new input stream
m_in = in;
}
/***************************************************************************
* Closes the input stream.
* Also disassociates the underlying input (Reader) stream from
* this input stream.
*
* @since 1.1, 2001-04-23
*/
public void close()
{
try
{
// Close the input stream
if (m_in != null)
m_in.close();
}
catch (IOException ex)
{
// Ignored
}
m_in = null;
}
/***************************************************************************
* Reads the next text line from the input stream.
*
* @return
* The next text line read from the input stream, or -1 if there are no more
* lines to read (i.e., the end of file was reached).
*
* @throws IOException
* Thrown if an I/O (read) error occurs.
*
* @since 1.1, 2001-04-23
*/
public TextLineI readLine()
throws IOException
{
TextLineI line;
// Create a new (empty) text line
line = new TextLine();
// Read the next input text line
if (readLine(line))
{
// Successfully read a text line
return (line);
}
else
{
// Read failed, end of file
return (null);
}
}
/***************************************************************************
* Reads the next text line from the input stream.
*
* @param ln
* The text line object to read the next line into.
* Cannot be null.
*
* @return
* True if a text line was successfully read from the input stream into
* ln, or false if there are no more lines to read (i.e., the end
* of file was reached).
*
* @throws IOException
* Thrown if an I/O (read) error occurs.
*
* @since 1.1, 2001-04-23
*/
public boolean readLine(TextLineI ln)
throws IOException
{
/*+++ INCOMPLETE
...read a text line, one char at a time, up to the next newline
...
+++*/
return (false);
}
}
// End LineInputStream.java