|
terp - the Codemesh Modular Template Interpreter v1.3.309 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.codemesh.terp.api.CharacterStream
public class CharacterStream
The wrapper type for various input sources. This type is used internally by the TokenStream types but for ease of programmatic use, all CharacterStream constructors have been exposed in the TokenStream types as well. This means that you don't have to create a CharacterStream first and then use it as an argument for a TokenStream constructor but you can use the CharacterStream constructor arguments directly to create a TokenStream. As a consequence, you will rarely use a CharacterStream directly.
| Field Summary | |
|---|---|
protected java.util.Stack<com.codemesh.terp.api.CharacterStream.StreamState> |
marks
|
protected java.lang.String |
theExtension
|
protected java.lang.String |
theInput
|
protected java.lang.String |
theName
|
protected java.lang.String |
theRoot
|
protected int |
theSize
|
protected java.lang.Object |
theSource
|
protected com.codemesh.terp.api.CharacterStream.StreamState |
theState
|
protected long |
theTimestamp
|
| Constructor Summary | |
|---|---|
CharacterStream(java.io.File source)
Creates a stream that reads from the given file. |
|
CharacterStream(java.io.File source,
java.lang.String encoding)
Creates a stream that reads from the given string in the given encoding. |
|
CharacterStream(java.io.InputStream is)
Creates a stream that reads from the given input stream. |
|
CharacterStream(java.io.InputStream is,
java.lang.String encoding)
Creates a stream that reads from the given input stream. |
|
CharacterStream(java.lang.Object theSource,
java.lang.String encoding,
boolean bBuiltin)
|
|
CharacterStream(java.io.Reader r)
Creates a stream that reads from the given reader. |
|
CharacterStream(java.lang.String source)
Creates a stream that reads from the given string. |
|
CharacterStream(java.net.URI sourceUri)
Creates a stream that reads from the given uri. |
|
CharacterStream(java.net.URI sourceUri,
java.lang.String encoding)
Creates a stream that reads from the given uri in the given encoding. |
|
CharacterStream(java.net.URL sourceUrl)
Creates a stream that reads from the given url. |
|
CharacterStream(java.net.URL sourceUrl,
java.lang.String encoding)
Creates a stream that reads from the given url in the given encoding. |
|
| Method Summary | |
|---|---|
int |
getColumn()
Returns the current column in the source. |
int |
getIndex()
Returns the current position in the source. |
int |
getLine()
Returns the current line in the source. |
java.lang.String |
getRange(int start,
int end)
Returns the source substring for the given indices or the empty string if the indices are invalid. |
InputSource |
getSource()
Returns the input source of the stream. |
int |
LA(int offset)
Returns the next lookahead character. |
void |
mark()
Marks the current position in source. |
boolean |
match(int ch)
Returns true if the next character is equal to the given character and advances the current position accordingly. |
boolean |
match(int[] chs)
If the next character to be read matches one of the given array of characters, index is advanced and true is returned. |
boolean |
matchRange(int[] ranges)
If the next character to be read matches one of the given character ranges, index is advanced and true is returned. |
boolean |
matchRange(int lowest,
int highest)
If the next character to be read is in the given range of characters, index is advanced and true is returned. |
int |
next()
Returns the next character in the source. |
void |
read(java.lang.String encoding)
|
void |
rewind()
Forgets a previously marked position while restoring the current position to the marked position. |
void |
unmark()
Forgets a previously marked position while maintaining the current position. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.Object theSource
protected java.lang.String theName
protected java.lang.String theRoot
protected java.lang.String theExtension
protected java.lang.String theInput
protected int theSize
protected long theTimestamp
protected java.util.Stack<com.codemesh.terp.api.CharacterStream.StreamState> marks
protected com.codemesh.terp.api.CharacterStream.StreamState theState
| Constructor Detail |
|---|
public CharacterStream(java.lang.String source)
source - the string to read from.public CharacterStream(java.io.File source)
source - the file to read from.
public CharacterStream(java.io.File source,
java.lang.String encoding)
source - the string to read from.encoding - the file encoding.public CharacterStream(java.net.URI sourceUri)
sourceUri - the uri to read from.
public CharacterStream(java.net.URI sourceUri,
java.lang.String encoding)
sourceUri - the uri to read from.encoding - the content encoding.public CharacterStream(java.net.URL sourceUrl)
sourceUrl - the url to read from.
public CharacterStream(java.net.URL sourceUrl,
java.lang.String encoding)
sourceUrl - the url to read from.encoding - the content encoding.public CharacterStream(java.io.InputStream is)
is - the stream to read from.
public CharacterStream(java.io.InputStream is,
java.lang.String encoding)
is - the stream to read from.encoding - the content encoding.public CharacterStream(java.io.Reader r)
r - the reader to read from.
public CharacterStream(java.lang.Object theSource,
java.lang.String encoding,
boolean bBuiltin)
| Method Detail |
|---|
public void read(java.lang.String encoding)
public int getIndex()
public int getLine()
public int getColumn()
public int next()
public void mark()
unmark()
or a rewind().
public void unmark()
public void rewind()
public int LA(int offset)
offset - the offset from the current position. Negative values
are legal.
public boolean match(int ch)
ch - the character to look for.
public boolean match(int[] chs)
chs - the characters, one of which is to be matched.
public boolean matchRange(int lowest,
int highest)
lowest - the lower bound (inclusive) to be matched.highest - the upper bound (inclusive) to be matched.
public boolean matchRange(int[] ranges)
ranges - the character ranges, one of which is to be matched.
The ranges are represented as an even-sized array of integers. The sequence
of numbers is lowest0, highest0, lowest1, highest1, ..., lowest(n), highest(n).
public java.lang.String getRange(int start,
int end)
start - the first character's index.end - the last character's index.
public InputSource getSource()
|
terp - the Codemesh Modular Template Interpreter v1.3.309 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||