com.springsource.util.parser.manifest.internal
Class SimpleTokenStream
java.lang.Object
com.springsource.util.parser.manifest.internal.SimpleTokenStream
- All Implemented Interfaces:
- TokenStream
public class SimpleTokenStream
- extends java.lang.Object
- implements TokenStream
Concurrent Semantics
This class is thread safe.
- Author:
- Andy Clement
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
tokenStreamPosition
private int tokenStreamPosition
tokens
private java.util.List<Token> tokens
tokenStreamLen
private int tokenStreamLen
problems
private java.util.List<ManifestProblem> problems
sourceContext
private SourceContext sourceContext
SimpleTokenStream
SimpleTokenStream()
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
getCount
public int getCount()
- Specified by:
getCount
in interface TokenStream
- Returns:
- number of tokens in the stream
getPosition
public int getPosition()
- Specified by:
getPosition
in interface TokenStream
- Returns:
- position within the token stream
next
public Token next()
- Specified by:
next
in interface TokenStream
- Returns:
- the next token and consume it
setPosition
public void setPosition(int newPosition)
- Specified by:
setPosition
in interface TokenStream
- Parameters:
newPosition
- the new position to move to in the token stream
peek
public Token peek()
- Specified by:
peek
in interface TokenStream
- Returns:
- the next token but do not consume it
peekLast
public Token peekLast()
- Specified by:
peekLast
in interface TokenStream
peek
public Token peek(int offset)
- Specified by:
peek
in interface TokenStream
- Parameters:
offset
- the offset from the current TokenStream position, can be
negative.
- Returns:
- the token at that particular offset from the current position.
toFormattedString
public java.lang.String toFormattedString()
- Specified by:
toFormattedString
in interface TokenStream
toFormattedString
public java.lang.String toFormattedString(boolean includePositionsInOutput)
- Specified by:
toFormattedString
in interface TokenStream
addToken
void addToken(Token token)
containsProblems
public boolean containsProblems()
- Specified by:
containsProblems
in interface TokenStream
- Returns:
- true if problems were found whilst processing the input data
getProblems
public java.util.List<ManifestProblem> getProblems()
- Specified by:
getProblems
in interface TokenStream
- Returns:
- all the problems that occurred whilst processing the input data
getSourceContext
public SourceContext getSourceContext()
- Specified by:
getSourceContext
in interface TokenStream
- Returns:
- the source context which can be used to create improved messages
hasMore
public boolean hasMore()
- Specified by:
hasMore
in interface TokenStream
- Returns:
- true if there are still more tokens to process (ie. the position
is not yet at the end)
recordProblem
public void recordProblem(ManifestProblem manifestProblem)
- Specified by:
recordProblem
in interface TokenStream
setSourceContext
public void setSourceContext(SourceContext sourceContext)
lexComplete
public void lexComplete()
- Called by the lexer to indicate that population of the tokenStream is now
complete.