|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tribble.io.CharInputStreamDfl
public class CharInputStreamDfl
Default generic character input stream.
This is a default implementation of an input stream that is capable of
reading a single character at a time. Such a stream can be used as the
underlying character input stream for classes implementing the LexerI
interface.
This character stream handles various combinations of newline termination characters (LF, CR, and CR/LF pairs), returning a single newline character ('\n') for any given combination.
This also handles formfeed (FF) and null (NUL) characters, treating them as spaces (SP).
Tab (HT) characters are replaced with one or more spaces, to align on tabbed columns. By default, tabs are replaced with the appropriate number of spaces so as to align on 8-character columns, but this can be changed to a different width or disabled altogether.
LexerI
Field Summary | |
---|---|
static int |
DFL_TABSIZE
Default tab width. |
static int |
EOF
End of file character code. |
protected int |
m_colNo
Column position (of the last character read). |
protected java.io.Reader |
m_in
Input stream. |
protected DiagnosticOutputI |
m_out
Diagnostic output stream. |
protected int |
m_tabSp
Pending tab (HT) character replacement. |
protected int |
m_tabSz
Tab (HT) column width. |
protected int |
m_ungetc
Pushed-back (unread) character. |
(package private) static java.lang.String |
REV
Revision information. |
Constructor Summary | |
---|---|
CharInputStreamDfl()
Default constructor. |
|
CharInputStreamDfl(java.io.Reader in)
Constructor. |
|
CharInputStreamDfl(java.io.Reader in,
DiagnosticOutputI out)
Constructor. |
Method Summary | |
---|---|
void |
close()
Close the input stream. |
protected void |
finalize()
Finalization. |
int |
readChar()
Read the next character from the input stream. |
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. |
void |
setTabSize(int n)
Establish the tab (HT) column width. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static final java.lang.String REV
public static final int EOF
public static final int DFL_TABSIZE
protected java.io.Reader m_in
protected DiagnosticOutputI m_out
protected int m_ungetc
protected int m_colNo
protected int m_tabSz
protected int m_tabSp
Constructor Detail |
---|
public CharInputStreamDfl()
public CharInputStreamDfl(java.io.Reader in)
in
- The input stream from which to read characters.public CharInputStreamDfl(java.io.Reader in, DiagnosticOutputI out)
in
- The input stream from which to read characters.out
- The diagnostic output stream to write to.Method Detail |
---|
public void setOutput(DiagnosticOutputI out)
setOutput
in interface DiagnosticWriterI
out
- The diagnostic output stream.public void setInput(java.io.Reader in)
setInput
in interface CharInputStreamI
in
- The input stream from which to read characters.public void close()
close
in interface CharInputStreamI
public int readChar() throws java.io.IOException
This character stream handles various combinations of newline termination characters (LF, CR, and CR/LF pairs), returning a single newline character ('\n') for any given combination.
This stream also handles formfeed (FF) and null (NUL) characters, replacing them with spaces (SP).
Tab (HT) characters are replaced by one or more space (SP) characters, so
that the character following the tab is aligned on a tab-sized column.
Tab character replacement can be disabled by specifying a tab size of
zero (see setTabSize(int)
).
readChar
in interface CharInputStreamI
java.io.IOException
- Thrown if an I/O (read) error occurs.public void setTabSize(int n)
Setting a tab width of zero disables the replacing of tab (HT) characters with spaces, i.e., tab characters are read as is. The default tab width is 8.
n
- The tab column width.protected void finalize()
finalize
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |