|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.extex.scanner.base.TokenStreamBaseImpl
public class TokenStreamBaseImpl
This is the base implementation of a token stream. It has an internal stack of tokens which can be enlarged with push() or reduced with pop().
| Constructor Summary | |
|---|---|
TokenStreamBaseImpl(boolean isFile)
Creates a new object. |
|
TokenStreamBaseImpl(boolean isFile,
Tokens tokens)
Creates a new object. |
|
| Method Summary | |
|---|---|
boolean |
closeFileStream()
Close this stream if it is a file stream. |
Token |
get(TokenFactory factory,
Tokenizer tokenizer)
Get the next token from the token stream. |
Locator |
getLocator()
Getter for the locator. |
protected Token |
getNext(TokenFactory factory,
Tokenizer tokenizer)
Get the next token when the stack is empty. |
boolean |
isEof()
Test for end of file. |
boolean |
isEol()
Check to see if the token stream is currently at the end of line. |
boolean |
isFileStream()
Check whether the current stream is associated with a file to read from. |
void |
put(Token token)
Push back a token into the stream. |
void |
skipSpaces()
Setter for skipSpaces. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TokenStreamBaseImpl(boolean isFile)
isFile - indicator whether or not the token stream is assigned to
a file
public TokenStreamBaseImpl(boolean isFile,
Tokens tokens)
isFile - indicator whether or not the token stream is assigned to
a filetokens - the tokens to push to the stream initially| Method Detail |
|---|
public boolean closeFileStream()
closeFileStream in interface TokenStreamtrue if the closing was successfulTokenStream.closeFileStream()
public Token get(TokenFactory factory,
Tokenizer tokenizer)
throws ScannerException
get in interface TokenStreamfactory - the token factorytokenizer - the tokenizer
null if no more tokens are
available
ScannerException - in case of an errorTokenStream.get(
org.extex.scanner.type.token.TokenFactory,
org.extex.scanner.api.Tokenizer)public Locator getLocator()
getLocator in interface TokenStreamTokenStream.getLocator()
protected Token getNext(TokenFactory factory,
Tokenizer tokenizer)
throws ScannerException
factory - the factory for new tokenstokenizer - the classifies for characters
null
ScannerException - in case of an error
public boolean isEof()
throws ScannerException
isEof in interface TokenStreamtrue iff the stream is at its end
ScannerException - in case of an error
public boolean isEol()
throws ScannerException
isEol in interface TokenStreamtrue if the stream is at end of line
ScannerException - in case that an error has been encountered.
Especially if an IO exceptions occurs it is delivered as chained
exception in a ScannerException.TokenStream.isEol()public boolean isFileStream()
isFileStream in interface TokenStreamtrue if the stream is a file streamTokenStream.isFileStream()public void put(Token token)
null then nothing happens:
a null token is not pushed!
Note that it is up to the implementation to accept tokens not produced with the token factory for push back. In general the behavior in such a case is not defined and should be avoided.
put in interface TokenStreamtoken - the token to push backTokenStream.put(
org.extex.scanner.type.token.Token)public void skipSpaces()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||