java.lang.Object
java.io.Reader
java.io.FilterReader
com.go.trove.io.PositionReader
com.go.trove.io.PushbackPositionReader
com.go.trove.io.SourceReader
- public class SourceReader
- extends PushbackPositionReader
The SourceReader provides several services for reading source input.
It calculates line numbers, position in the source file, supports two
character pushback, extracts code from text that allows mixed code and
plain text, and it processes unicode escape sequences that appear in
source code.
Readers return -1 when the end of the stream, has been reached, and so
does SourceReader. SourceReader will also return other special negative
values to indicate a tag substitution. ENTER_CODE is returned to indicate
that characters read are in source code, and ENTER_TEXT is returned to
indicate that characters read are in plain text. The first character read
from a SourceReader is either ENTER_CODE or ENTER_TEXT;
- Version:
- 18 , 4/26/01
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ENTER_CODE
public static final int ENTER_CODE
- See Also:
- Constant Field Values
ENTER_TEXT
public static final int ENTER_TEXT
- See Also:
- Constant Field Values
mUnicodeReader
private UnicodeReader mUnicodeReader
mTagReader
private TagReader mTagReader
mClosed
private boolean mClosed
mLine
private int mLine
mFirst
private int mFirst
mBeginTag
private java.lang.String mBeginTag
mEndTag
private java.lang.String mEndTag
SourceReader
public SourceReader(java.io.Reader source,
java.lang.String beginTag,
java.lang.String endTag)
- The begin and end tags for a SourceReader are optional. If the begin
tag is null or has zero length, then the SourceReader starts reading
characters as if they were source code.
If the end tag is null or has zero length, then a source code
region continues to the end of the input Reader's characters.
SourceReader
public SourceReader(java.io.Reader source,
java.lang.String beginTag,
java.lang.String endTag,
boolean inCode)
- The begin and end tags for a SourceReader are optional. If the begin
tag is null or has zero length, then the SourceReader starts reading
characters as if they were source code.
If the end tag is null or has zero length, then a source code
region continues to the end of the input Reader's characters.
createReader
private static java.io.Reader createReader(java.io.Reader source,
java.lang.String beginTag,
java.lang.String endTag)
getBeginTag
public java.lang.String getBeginTag()
getEndTag
public java.lang.String getEndTag()
read
public int read()
throws java.io.IOException
- All newline character patterns are are converted to \n.
- Overrides:
read in class PushbackPositionReader
getLineNumber
public int getLineNumber()
getEndPosition
public int getEndPosition()
- The position in the reader where the last read character ended. The
position of the first character read from a Reader is zero.
The end position is usually the same as the start position, but
sometimes a SourceReader may combine multiple characters into a
single one.
ignoreTags
public void ignoreTags(boolean ignore)
isClosed
public boolean isClosed()
close
public void close()
throws java.io.IOException
- Description copied from class:
java.io.FilterReader
- This method closes the stream by calling the
close() method
of the underlying stream.
- Overrides:
close in class PositionReader
unreadHook
protected void unreadHook(int c)
- Description copied from class:
PushbackPositionReader
- A hook call from the unread method(s). Every unread character is
passed to this method.
- Overrides:
unreadHook in class PushbackPositionReader
main
public static void main(java.lang.String[] arg)
throws java.lang.Exception
- Simple test program