tribble.io
Class LineToCharInputStream

java.lang.Object
  extended by tribble.io.LineToCharInputStream
All Implemented Interfaces:
CharInputStreamI, DiagnosticWriterI

public class LineToCharInputStream
extends java.lang.Object
implements CharInputStreamI, DiagnosticWriterI

Input stream which converts lines of text into single characters.

This interface is used to implement a variant of a character input stream, which is capable of reading a single character at a time from an underlying text line input stream. Such a stream can be used to read the underlying source text for a lexical analyzer (lexer), such as the LexerI interface.

Since:
2001-04-22
Version:
$Revision: 1.3 $ $Date: 2003/01/25 18:54:04 $
Author:
David R. Tribble, david@tribble.com.
Copyright 2001-2003 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 Also:
LexerI, CharInputStreamI

Field Summary
protected  LineInputStreamI m_in
          Text line input stream.
protected  int m_len
          Length of the current text line.
protected  int m_nexti
          Position of next character to read from the current text line.
protected  DiagnosticOutputI m_out
          Diagnostic output stream.
protected  java.lang.String m_text
          Current input text line.
(package private) static java.lang.String REV
          Revision information.
 
Constructor Summary
LineToCharInputStream()
          Default constructor.
LineToCharInputStream(LineInputStreamI in)
          Constructor.
LineToCharInputStream(java.io.Reader in)
          Constructor.
 
Method Summary
 void close()
          Close the input stream.
 int readChar()
          Read the next character from the input stream.
 void setInput(LineInputStreamI in)
          Establish the text line input stream from which to read lines of text, from which individual characters are read.
 void setInput(java.io.Reader in)
          Establish the input stream from which to read characters.
 void setOutput(DiagnosticOutputI out)
          Establish the output stream to which diagnostic messages (warning and error messages) are written during parsing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values

m_in

protected LineInputStreamI m_in
Text line input stream.


m_out

protected DiagnosticOutputI m_out
Diagnostic output stream.


m_text

protected java.lang.String m_text
Current input text line.


m_len

protected int m_len
Length of the current text line.


m_nexti

protected int m_nexti
Position of next character to read from the current text line.

Constructor Detail

LineToCharInputStream

public LineToCharInputStream()
Default constructor.

Since:
1.1, 2001-04-22

LineToCharInputStream

public LineToCharInputStream(LineInputStreamI in)
Constructor.

Parameters:
in - The text line input stream for this character stream.
Since:
1.1, 2001-04-22

LineToCharInputStream

public LineToCharInputStream(java.io.Reader in)
Constructor.

Parameters:
in - The input stream for this character stream.
Since:
1.1, 2001-04-22
Method Detail

setOutput

public void setOutput(DiagnosticOutputI out)
Establish the output stream to which diagnostic messages (warning and error messages) are written during parsing.

Specified by:
setOutput in interface DiagnosticWriterI
Parameters:
out - The error output stream.
Since:
1.1, 2001-04-22

setInput

public void setInput(LineInputStreamI in)
Establish the text line input stream from which to read lines of text, from which individual characters are read.

Parameters:
in - The text line input stream from which to read.
Since:
1.1, 2001-04-22

setInput

public void setInput(java.io.Reader in)
Establish the input stream from which to read characters.

Specified by:
setInput in interface CharInputStreamI
Parameters:
in - The input stream from which to read characters.
Since:
1.1, 2001-04-22

close

public void close()
Close the input stream.

Specified by:
close in interface CharInputStreamI
Since:
1.1, 2001-04-22

readChar

public int readChar()
             throws java.io.IOException
Read the next character from the input stream.

Specified by:
readChar in interface CharInputStreamI
Returns:
The next character code read from the input stream, or -1 if there are no more characters to read (i.e., the end of the input stream was reached).
Throws:
java.io.IOException - Thrown if an I/O (read) error occurs.
Since:
1.1, 2001-04-22