Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.go.trove.io
Class SourceReader  view SourceReader download SourceReader.java

java.lang.Object
  extended byjava.io.Reader
      extended byjava.io.FilterReader
          extended bycom.go.trove.io.PositionReader
              extended bycom.go.trove.io.PushbackPositionReader
                  extended bycom.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

Nested Class Summary
private static class SourceReader.Tester
           
 
Field Summary
static int ENTER_CODE
           
static int ENTER_TEXT
           
private  java.lang.String mBeginTag
           
private  boolean mClosed
           
private  java.lang.String mEndTag
           
private  int mFirst
           
private  int mLine
           
private  TagReader mTagReader
           
private  UnicodeReader mUnicodeReader
           
 
Fields inherited from class com.go.trove.io.PushbackPositionReader
 
Fields inherited from class com.go.trove.io.PositionReader
mPosition, mPosReader
 
Fields inherited from class java.io.FilterReader
in
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
SourceReader(java.io.Reader source, java.lang.String beginTag, java.lang.String endTag)
          The begin and end tags for a SourceReader are optional.
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.
 
Method Summary
 void close()
          This method closes the stream by calling the close() method of the underlying stream.
private static java.io.Reader createReader(java.io.Reader source, java.lang.String beginTag, java.lang.String endTag)
           
 java.lang.String getBeginTag()
           
 int getEndPosition()
          The position in the reader where the last read character ended.
 java.lang.String getEndTag()
           
 int getLineNumber()
           
 void ignoreTags(boolean ignore)
           
 boolean isClosed()
           
static void main(java.lang.String[] arg)
          Simple test program
 int read()
          All newline character patterns are are converted to \n.
protected  void unreadHook(int c)
          A hook call from the unread method(s).
 
Methods inherited from class com.go.trove.io.PushbackPositionReader
getStartPosition, peek, unread, unread
 
Methods inherited from class com.go.trove.io.PositionReader
getNextPosition, read
 
Methods inherited from class java.io.FilterReader
mark, markSupported, ready, reset, skip
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

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.

Method Detail

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