public class JsonTokenizer extends Object
Constructor and Description |
---|
JsonTokenizer(InputStream in)
Create a JSON tokenizer that reads from the input steam.
|
Modifier and Type | Method and Description |
---|---|
JsonToken |
expect(String message)
Expect a new JSON token on the stream.
|
JsonToken |
expectNumber(String message)
Expect a JSON number.
|
JsonToken |
expectString(String message)
Expect a string literal JSON token.
|
char |
expectSymbol(String message,
char... symbols)
Expect a string literal JSON token.
|
String |
getLine(int line)
Returns the line requested.
|
boolean |
hasNext()
Whether there is another token on the stream.
|
JsonToken |
next()
Returns the next token on the stream, or null if there are no more JSON
tokens on the stream.
|
JsonToken |
peek(String message)
Return the next token or throw an exception.
|
public JsonTokenizer(InputStream in)
in
- Input stream to parse.public JsonToken expect(String message) throws JsonException, IOException
message
- Message to add to exception if there are no more JSON
tokens on the stream.JsonException
- If no more tokens, or the token is illegally
formatted.IOException
- If unable to read from stream.public JsonToken expectString(String message) throws IOException, JsonException
message
- Message to add to exception if there are no more JSON
tokens on the stream.JsonException
- If no more tokens, or the token is illegally
formatted.IOException
- If unable to read from stream.public JsonToken expectNumber(String message) throws IOException, JsonException
message
- Message to add to exception if there are no more JSON
tokens on the stream.JsonException
- If no more tokens, or the token is illegally
formatted.IOException
- If unable to read from stream.public char expectSymbol(String message, char... symbols) throws IOException, JsonException
message
- Message to add to exception if there are no more JSON
tokens on the stream.symbols
- List of symbol characters to expect. IfJsonException
- If no more tokens, or the token is illegally
formatted.IOException
- If unable to read from stream.public boolean hasNext() throws IOException, JsonException
JsonException
- If the next token is illegally formatted.IOException
- If unable to read from stream.public JsonToken peek(String message) throws IOException, JsonException
message
- Message to add to exception if there are no more JSON
tokens on the stream.JsonException
- If the next token is illegally formatted.IOException
- If unable to read from stream.public JsonToken next() throws IOException, JsonException
JsonException
- If the next token is illegally formatted.IOException
- If unable to read from stream.public String getLine(int line) throws IOException
line
- The line number (1 .. N)IOException
- If unable to read from the string.IllegalArgumentException
- If the line number requested is less
than 1.Copyright © 2017. All rights reserved.