Interface JsopReader
- All Known Implementing Classes:
JsopStream,JsopTokenizer
public interface JsopReader
A reader for Json and Jsop strings.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe token type of a comment, if supported by the reader.static final intThe token type that signals the end of the stream.static final intThe token type of a parse error.static final intThe token type of the value "false".static final intThe token type of an identifier (an unquoted string), if supported by the reader.static final intThe token type of "null".static final intThe token type of a number value.static final intThe token type of a string value.static final intThe token type of the value "true". -
Method Summary
Modifier and TypeMethodDescription@Nullable StringgetToken()Get the last token value if the the token type was STRING or NUMBER.intGet the token type of the last token.booleanmatches(int type) Read a token which must match a given token type.intread()Read a token and return the token type.read(int type) Read a token which must match a given token type.@Nullable StringReturn the row (escaped) token.@Nullable StringRead a string.voidReset the position to 0, so that to restart reading.
-
Field Details
-
END
static final int ENDThe token type that signals the end of the stream.- See Also:
-
STRING
static final int STRINGThe token type of a string value.- See Also:
-
NUMBER
static final int NUMBERThe token type of a number value.- See Also:
-
TRUE
static final int TRUEThe token type of the value "true".- See Also:
-
FALSE
static final int FALSEThe token type of the value "false".- See Also:
-
NULL
static final int NULLThe token type of "null".- See Also:
-
ERROR
static final int ERRORThe token type of a parse error.- See Also:
-
IDENTIFIER
static final int IDENTIFIERThe token type of an identifier (an unquoted string), if supported by the reader.- See Also:
-
COMMENT
static final int COMMENTThe token type of a comment, if supported by the reader.- See Also:
-
-
Method Details
-
read
Read a token which must match a given token type.- Parameters:
type- the token type- Returns:
- the token (null when reading a null value)
- Throws:
IllegalStateException- if the token type doesn't match
-
readString
Read a string.- Returns:
- the de-escaped string (null when reading a null value)
- Throws:
IllegalStateException- if the token type doesn't match
-
read
int read()Read a token and return the token type.- Returns:
- the token type
-
matches
boolean matches(int type) Read a token which must match a given token type.- Parameters:
type- the token type- Returns:
- true if there was a match
-
readRawValue
Return the row (escaped) token.- Returns:
- the escaped string (null when reading a null value)
-
getToken
Get the last token value if the the token type was STRING or NUMBER. For STRING, the text is decoded; for NUMBER, it is returned as parsed. In all other cases the result is undefined.- Returns:
- the token
-
getTokenType
int getTokenType()Get the token type of the last token. The token type is one of the known types (END, STRING, NUMBER,...), or, for Jsop tags such as "+", "-", it is the Unicode character code of the tag.- Returns:
- the token type
-
resetReader
void resetReader()Reset the position to 0, so that to restart reading.
-