public class DefinitionLexer extends AbstractLexer implements DefinitionTokens
DefinitionLexer is an implementation of the
Lexer interface for lexing a property definition.
Specifically, it is used for retrieving the pieces that make up a
property definition, the name, assignment symbol, and the
value.
For parsing purposes, if you wish to skip the assignment operator,
call setSkipSymbols(true).
Lexer,
DefinitionTokens,
PropertiesLexerAbstractLexer.DefaultLexerTokencurrentPos, textBufferTK_NAME, TK_SYMBOL, TK_VALUETK_EOF, TK_NOT_FOUND| Constructor and Description |
|---|
DefinitionLexer()
Constructs a default
DefinitionLexer with a starting
position of 0. |
DefinitionLexer(PropertyFileLexerSetup lexerSetup)
A constructor that parameterizes the lexerSetup.
|
| Modifier and Type | Method and Description |
|---|---|
void |
backup()
Unlexes the last found token.
|
int |
lex(LexerToken lexedToken)
Scans the text buffer at the current position and returns the
token that was found.
|
void |
setPosition(int offset)
Sets the current lex (read) position to the given offset in the
buffer.
|
void |
setSkipSymbols(boolean skipSymbols)
Sets whether the
TagLexer should generate tokens
for the assignment symbol. |
static java.lang.String |
tokenToString(int token)
Utility routine to map the token to a string representation of
the token (for debug printing.)
|
static java.lang.String |
tokenToText(int token)
Utility routine to map the token to the original text (if
retrievable) of the token (for debug printing.)
|
createLexerToken, getTextBuffer, setTextBufferpublic DefinitionLexer()
DefinitionLexer with a starting
position of 0. Clients must call setTextBuffer() to
initialize the text buffer used for the Lexer. To start lexing
from an offset other than 0, call setPosition().public DefinitionLexer(PropertyFileLexerSetup lexerSetup)
lexerSetup - public void setSkipSymbols(boolean skipSymbols)
TagLexer should generate tokens
for the assignment symbol.skipSymbols - true to skip the assignment symbolpublic int lex(LexerToken lexedToken)
lexedToken instance passed in to the
call.lex in interface Lexerlex in class AbstractLexerlexedToken - the instance passed in where token info is storedlexedToken.getToken() (for convenience)public void backup()
lex()
will return the last token and offset information found.backup in interface Lexerbackup in class AbstractLexerpublic void setPosition(int offset)
setPosition in interface LexersetPosition in class AbstractLexeroffset - the offset for the next lex() operation.public static java.lang.String tokenToString(int token)
token - the token to mappublic static java.lang.String tokenToText(int token)
token - the token to map