Class JsonLexer
java.lang.Object
de.monticore.symboltable.serialization.JsonLexer
This class is responsible to tokenize a String that encoded as JSON. The length of the input,
thus, is limited by the maximum length of a String.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected Stringprotected NumberLexerprotected JsonTokenprotected intprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected JsonTokentry to read a number starting at the current locationprotected JsonTokenchecks, if the current input is a valid JSON String, i.e.Returns the part of the input that has not been lexed yet (e.g., for prinbooleanhasNext()returns truee, iff the end of the String lexed so far is not reached.protected charla(int i) Returns the character at the i-th position from the current position of the input.peek()reads the next token of the input, without consuming it.poll()returns the next token and removes it
-
Field Details
-
json
-
pos
protected int pos -
peeked
-
numbers
-
WHITESPACE_CHARACTERS
- See Also:
-
HEX_DIGITS
- See Also:
-
-
Constructor Details
-
JsonLexer
The lexer tokenizes the passed input String.- Parameters:
input-
-
-
Method Details
-
hasNext
public boolean hasNext()returns truee, iff the end of the String lexed so far is not reached.- Returns:
-
getRemainder
Returns the part of the input that has not been lexed yet (e.g., for prin- Returns:
-
peek
reads the next token of the input, without consuming it. In Json, each kind of token can be identified by its first character.- Returns:
-
la
protected char la(int i) Returns the character at the i-th position from the current position of the input.- Parameters:
i-- Returns:
-
poll
returns the next token and removes it- Returns:
-
checkNumber
try to read a number starting at the current location- Returns:
-
checkString
checks, if the current input is a valid JSON String, i.e. if it is conform to the regex: String regex = "" + "\"" //start with '"' + "(" //begin iteration of characters + "[^\\\"\\\\]" //every character except '"' or "\" + "|\\\\u[0-9A-Fa-f]{4}" //or unicode escape sequence + "|\\\\[bfnrt\"/\\\\]" // or other escape sequence + ")*" //end iteration of characters + "\""; //end with '"'- Returns:
-