Class AbstractTokenizer
java.lang.Object
org.pipservices3.expressions.tokenizers.AbstractTokenizer
- All Implemented Interfaces:
ITokenizer
- Direct Known Subclasses:
CsvTokenizer
,ExpressionTokenizer
,GenericTokenizer
,MustacheTokenizer
Implements an abstract tokenizer class.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
getCharacterState
(int symbol) A token state to process comments.Decodes quoted strings.Merges whitespaces.A token state to process numbers.A token state to process quoted strings.The stream scanner to tokenize.Skips comments.Skips End-Of-File token at the end of stream.Skip unknown charactersSkips whitespaces.A token state to process symbols (single like "=" or muti-character like "<>")Unifies numbers: "Integers" and "Floats" makes just "Numbers"A token state to process white space delimiters.A token state to process words or indentificators.Checks if there is the next token exist.Gets the next token from the scanner.protected Token
void
setCharacterState
(int fromSymbol, int toSymbol, ITokenizerState state) void
setCommentState
(ICommentState value) A token state to process comments.void
setDecodeStrings
(boolean value) Decodes quoted strings.void
setMergeWhitespaces
(boolean value) Merges whitespaces.void
setNumberState
(INumberState value) A token state to process numbers.void
setQuoteState
(IQuoteState value) A token state to process quoted strings.void
setScanner
(IScanner value) The stream scanner to tokenize.void
setSkipComments
(boolean value) Skips comments.void
setSkipEof
(boolean value) Skips End-Of-File token at the end of stream.void
setSkipUnknown
(boolean value) Skip unknown charactersvoid
setSkipWhitespaces
(boolean value) Skips whitespaces.void
setSymbolState
(ISymbolState value) A token state to process symbols (single like "=" or muti-character like "<>")void
setUnifyNumbers
(boolean value) Unifies numbers: "Integers" and "Floats" makes just "Numbers"void
A token state to process white space delimiters.void
setWordState
(IWordState value) A token state to process words or indentificators.tokenizeBuffer
(String buffer) Tokenizes a string buffer into a list of tokens structures.tokenizeBufferToStrings
(String buffer) Tokenizes a string buffer into a list of strings.tokenizeStream
(IScanner scanner) Tokenizes a textual stream into a list of token structures.tokenizeStreamToStrings
(IScanner scanner) Tokenizes a textual stream into a list of strings.
-
Field Details
-
_scanner
-
_nextToken
-
_lastTokenType
-
-
Constructor Details
-
AbstractTokenizer
public AbstractTokenizer()
-
-
Method Details
-
getSkipUnknown
Description copied from interface:ITokenizer
Skip unknown characters- Specified by:
getSkipUnknown
in interfaceITokenizer
-
setSkipUnknown
public void setSkipUnknown(boolean value) Description copied from interface:ITokenizer
Skip unknown characters- Specified by:
setSkipUnknown
in interfaceITokenizer
-
getSkipWhitespaces
Description copied from interface:ITokenizer
Skips whitespaces.- Specified by:
getSkipWhitespaces
in interfaceITokenizer
-
setSkipWhitespaces
public void setSkipWhitespaces(boolean value) Description copied from interface:ITokenizer
Skips whitespaces.- Specified by:
setSkipWhitespaces
in interfaceITokenizer
-
getSkipComments
Description copied from interface:ITokenizer
Skips comments.- Specified by:
getSkipComments
in interfaceITokenizer
-
setSkipComments
public void setSkipComments(boolean value) Description copied from interface:ITokenizer
Skips comments.- Specified by:
setSkipComments
in interfaceITokenizer
-
getSkipEof
Description copied from interface:ITokenizer
Skips End-Of-File token at the end of stream.- Specified by:
getSkipEof
in interfaceITokenizer
-
setSkipEof
public void setSkipEof(boolean value) Description copied from interface:ITokenizer
Skips End-Of-File token at the end of stream.- Specified by:
setSkipEof
in interfaceITokenizer
-
getMergeWhitespaces
Description copied from interface:ITokenizer
Merges whitespaces.- Specified by:
getMergeWhitespaces
in interfaceITokenizer
-
setMergeWhitespaces
public void setMergeWhitespaces(boolean value) Description copied from interface:ITokenizer
Merges whitespaces.- Specified by:
setMergeWhitespaces
in interfaceITokenizer
-
getUnifyNumbers
Description copied from interface:ITokenizer
Unifies numbers: "Integers" and "Floats" makes just "Numbers"- Specified by:
getUnifyNumbers
in interfaceITokenizer
-
setUnifyNumbers
public void setUnifyNumbers(boolean value) Description copied from interface:ITokenizer
Unifies numbers: "Integers" and "Floats" makes just "Numbers"- Specified by:
setUnifyNumbers
in interfaceITokenizer
-
getDecodeStrings
Description copied from interface:ITokenizer
Decodes quoted strings.- Specified by:
getDecodeStrings
in interfaceITokenizer
-
setDecodeStrings
public void setDecodeStrings(boolean value) Description copied from interface:ITokenizer
Decodes quoted strings.- Specified by:
setDecodeStrings
in interfaceITokenizer
-
getCommentState
Description copied from interface:ITokenizer
A token state to process comments.- Specified by:
getCommentState
in interfaceITokenizer
-
setCommentState
Description copied from interface:ITokenizer
A token state to process comments.- Specified by:
setCommentState
in interfaceITokenizer
-
getNumberState
Description copied from interface:ITokenizer
A token state to process numbers.- Specified by:
getNumberState
in interfaceITokenizer
-
setNumberState
Description copied from interface:ITokenizer
A token state to process numbers.- Specified by:
setNumberState
in interfaceITokenizer
-
getQuoteState
Description copied from interface:ITokenizer
A token state to process quoted strings.- Specified by:
getQuoteState
in interfaceITokenizer
-
setQuoteState
Description copied from interface:ITokenizer
A token state to process quoted strings.- Specified by:
setQuoteState
in interfaceITokenizer
-
getSymbolState
Description copied from interface:ITokenizer
A token state to process symbols (single like "=" or muti-character like "<>")- Specified by:
getSymbolState
in interfaceITokenizer
-
setSymbolState
Description copied from interface:ITokenizer
A token state to process symbols (single like "=" or muti-character like "<>")- Specified by:
setSymbolState
in interfaceITokenizer
-
getWhitespaceState
Description copied from interface:ITokenizer
A token state to process white space delimiters.- Specified by:
getWhitespaceState
in interfaceITokenizer
-
setWhitespaceState
Description copied from interface:ITokenizer
A token state to process white space delimiters.- Specified by:
setWhitespaceState
in interfaceITokenizer
-
getWordState
Description copied from interface:ITokenizer
A token state to process words or indentificators.- Specified by:
getWordState
in interfaceITokenizer
-
setWordState
Description copied from interface:ITokenizer
A token state to process words or indentificators.- Specified by:
setWordState
in interfaceITokenizer
-
getScanner
Description copied from interface:ITokenizer
The stream scanner to tokenize.- Specified by:
getScanner
in interfaceITokenizer
-
setScanner
Description copied from interface:ITokenizer
The stream scanner to tokenize.- Specified by:
setScanner
in interfaceITokenizer
-
getCharacterState
-
setCharacterState
- Throws:
Exception
-
clearCharacterStates
public void clearCharacterStates() -
hasNextToken
Description copied from interface:ITokenizer
Checks if there is the next token exist.- Specified by:
hasNextToken
in interfaceITokenizer
- Returns:
true
if scanner has the next token.- Throws:
Exception
-
nextToken
Description copied from interface:ITokenizer
Gets the next token from the scanner.- Specified by:
nextToken
in interfaceITokenizer
- Returns:
- Next token of
null
if there are no more tokens left. - Throws:
Exception
-
readNextToken
- Throws:
Exception
-
tokenizeStream
Description copied from interface:ITokenizer
Tokenizes a textual stream into a list of token structures.- Specified by:
tokenizeStream
in interfaceITokenizer
- Parameters:
scanner
- A textual stream to be tokenized.- Returns:
- A list of token structures.
- Throws:
Exception
-
tokenizeBuffer
Description copied from interface:ITokenizer
Tokenizes a string buffer into a list of tokens structures.- Specified by:
tokenizeBuffer
in interfaceITokenizer
- Parameters:
buffer
- A string buffer to be tokenized.- Returns:
- A list of token structures.
- Throws:
Exception
-
tokenizeStreamToStrings
Description copied from interface:ITokenizer
Tokenizes a textual stream into a list of strings.- Specified by:
tokenizeStreamToStrings
in interfaceITokenizer
- Parameters:
scanner
- A textual stream to be tokenized.- Returns:
- A list of token strings.
- Throws:
Exception
-
tokenizeBufferToStrings
Description copied from interface:ITokenizer
Tokenizes a string buffer into a list of strings.- Specified by:
tokenizeBufferToStrings
in interfaceITokenizer
- Parameters:
buffer
- A string buffer to be tokenized.- Returns:
- A list of token strings.
- Throws:
Exception
-