public interface JsonPullParser extends Closeable
JsonPullParser is an event based JSON parser. It
reports it's current JsonState
and, depending on that JsonState, allows different ways to consume
the underlying JSON document.| Modifier and Type | Method and Description |
|---|---|
void |
beginArray()
Ensures that the
current
JsonState is JsonState.ARRAY_BEGIN and consumes the
beginning of a JSON array. |
void |
beginDocument()
Ensures that the
current
JsonState is JsonState.DOCUMENT_BEGIN and consumes the
begin of the JSON document. |
void |
beginObject()
Ensures that the
current
JsonState is JsonState.OBJECT_BEGIN and consumes the
beginning of a JSON object. |
JsonState |
currentState()
Reads, if necessary, from the underlying Reader and describes the current
JsonState of this JsonSourcePullParser, which describes
the next type of value or structural element of the JSON document. |
void |
endArray()
|
void |
endDocument()
Ensures that the
current
JsonState is JsonState.DOCUMENT_END and consumes the end
of the JSON document. |
void |
endObject()
|
int |
getColumn()
Returns the
column that corresponds to the
current position of the underlying JsonSource in the character
sequence, as if the character source was a regular file. |
int |
getLine()
Returns the
line that corresponds to the
current position of the underlying JsonSource in the character
sequence, as if the character source was a regular file. |
boolean |
hasNext()
Returns whether the current JSON array or JSON object has more elements.
|
boolean |
nextBoolean()
Ensures that the
current
JsonState is JsonState.BOOLEAN and consumes and returns
the corresponding value. |
byte |
nextByte()
Ensures that the
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value as a byte. |
char |
nextCharacter()
Ensures that the
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value as a char. |
double |
nextDouble()
Ensures that the
current
JsonState is JsonState.DOUBLE and consumes and returns
the corresponding value. |
float |
nextFloat()
Ensures that the
current
JsonState is JsonState.DOUBLE and consumes and returns
the corresponding value as a float. |
int |
nextInteger()
Ensures that the
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value as a int. |
long |
nextLong()
Ensures that the
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value. |
String |
nextName()
Ensures that the
current
JsonState is JsonState.NAME and consumes and returns the
corresponding name of a JSON object entry. |
void |
nextNull()
Ensures that the
current
JsonState is JsonState.NULL and consumes the
null The next JsonState describes either the next
sibling value of this JSON value or the end of surrounding JSON array or
JSON object. |
short |
nextShort()
Ensures that the
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value as a short. |
String |
nextString()
Ensures that the
current
JsonState is JsonState.STRING and consumes and returns
the corresponding value. |
Reader |
readString()
Ensures that the
current
JsonState is JsonState.STRING and return a Reader
that consumes the corresponding value. |
void |
skipValue()
Skips the current JSON value.
|
boolean hasNext()
throws JsonSyntaxException,
IOException
JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.JsonState currentState() throws JsonSyntaxException, IOException
JsonState of this JsonSourcePullParser, which describes
the next type of value or structural element of the JSON document.JsonState.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.void beginDocument()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.DOCUMENT_BEGIN and consumes the
begin of the JSON document. The next JsonState will be
JsonState.ARRAY_BEGIN or JsonState.OBJECT_BEGIN.IllegalStateException - If the current JsonState is not
JsonState.DOCUMENT_BEGIN.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.void endDocument()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.DOCUMENT_END and consumes the end
of the JSON document. The next JsonState will be
JsonState.SOURCE_END.
If this JsonSourcePullParser allows multiple documents in the
same JsonSource, The next JsonState will be
JsonState.DOCUMENT_BEGIN or JsonState.SOURCE_END.
IllegalStateException - If the current JsonState is not
JsonState.DOCUMENT_END.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.void beginArray()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.ARRAY_BEGIN and consumes the
beginning of a JSON array. The next JsonState describes either
the first value of this JSON array or the end of this JSON array.IllegalStateException - If the current JsonState is not
JsonState.ARRAY_BEGIN.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.void endArray()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.ARRAY_END and consumes the end of
the JSON array. The next JsonState describes either the next
sibling value of this JSON array or the end of the JSON document.IllegalStateException - If the current JsonState is not
JsonState.ARRAY_END.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.void beginObject()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.OBJECT_BEGIN and consumes the
beginning of a JSON object. The next JsonState describes either
the JsonSourcePullParser.nextName() of the first value of this
JSON object or the end of this JSON object.IllegalStateException - If the current JsonState is not
JsonState.OBJECT_BEGIN.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.void endObject()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.OBJECT_END and consumes the end of
the JSON object. The next JsonState describes either the next
sibling value of this JSON object or the end of the JSON document.IllegalStateException - If the current JsonState is not
JsonState.OBJECT_END.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.void nextNull()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.NULL and consumes the
null The next JsonState describes either the next
sibling value of this JSON value or the end of surrounding JSON array or
JSON object.IllegalStateException - If the current JsonState is not
JsonState.NULL.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.boolean nextBoolean()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.BOOLEAN and consumes and returns
the corresponding value. The next JsonState describes either the
next sibling value of this JSON value or the end of surrounding JSON
array or JSON object.boolean value.IllegalStateException - If the current JsonState is not
JsonState.BOOLEAN.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.byte nextByte()
throws ArithmeticException,
IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value as a byte. The next JsonState
describes either the next sibling value of this JSON value or the end of
surrounding JSON array or JSON object.byte value.ArithmeticException - If the value is too large or too small to fit into a
byte.IllegalStateException - If the current JsonState is not
JsonState.LONG.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.char nextCharacter()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value as a char. The next JsonState
describes either the next sibling value of this JSON value or the end of
surrounding JSON array or JSON object.char value.ArithmeticException - If the value is too large or too small to fit into a
char.IllegalStateException - If the current JsonState is not
JsonState.LONG.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.short nextShort()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value as a short. The next JsonState
describes either the next sibling value of this JSON value or the end of
surrounding JSON array or JSON object.short value.ArithmeticException - If the value is too large or too small to fit into a
short.IllegalStateException - If the current JsonState is not
JsonState.LONG.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.int nextInteger()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value as a int. The next JsonState
describes either the next sibling value of this JSON value or the end of
surrounding JSON array or JSON object.int value.ArithmeticException - If the value is too large or too small to fit into a
int.IllegalStateException - If the current JsonState is not
JsonState.LONG.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.long nextLong()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.LONG and consumes and returns the
corresponding value. The next JsonState describes either the next
sibling value of this JSON value or the end of surrounding JSON array or
JSON object.long value.IllegalStateException - If the current JsonState is not
JsonState.LONG.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.float nextFloat()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.DOUBLE and consumes and returns
the corresponding value as a float. The next JsonState
describes either the next sibling value of this JSON value or the end of
surrounding JSON array or JSON object.float value.IllegalStateException - If the current JsonState is not
JsonState.DOUBLE.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.double nextDouble()
throws IllegalStateException,
JsonSyntaxException,
IOException
current
JsonState is JsonState.DOUBLE and consumes and returns
the corresponding value. The next JsonState describes either the
next sibling value of this JSON value or the end of surrounding JSON
array or JSON object.double value.IllegalStateException - If the current JsonState is not
JsonState.DOUBLE.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.String nextString() throws IllegalStateException, JsonSyntaxException, IOException
current
JsonState is JsonState.STRING and consumes and returns
the corresponding value. The next JsonState describes either the
next sibling value of this JSON value or the end of surrounding JSON
array or JSON object.IllegalStateException - If the current JsonState is not
JsonState.STRING.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.Reader readString() throws IllegalStateException, JsonSyntaxException, IOException
current
JsonState is JsonState.STRING and return a Reader
that consumes the corresponding value. The next JsonState
describes either the next sibling value of this JSON value or the end of
surrounding JSON array or JSON object.
Important: the returned Reader must be
read completely or closed,
before the next call to any other method of this JsonPullParser.
Reader for the string value.IllegalStateException - If the current JsonState is not
JsonState.STRING.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.String nextName() throws IllegalStateException, JsonSyntaxException, IOException
current
JsonState is JsonState.NAME and consumes and returns the
corresponding name of a JSON object entry. The next JsonState
describes the corresponding value.IllegalStateException - If the current JsonState is not
JsonState.NAME.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.void skipValue()
throws JsonSyntaxException,
IOException
JsonState describes either
the next sibling value of this JSON value or the end of surrounding JSON
array or JSON object.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.int getLine()
line that corresponds to the
current position of the underlying JsonSource in the character
sequence, as if the character source was a regular file.int getColumn()
column that corresponds to the
current position of the underlying JsonSource in the character
sequence, as if the character source was a regular file.Copyright © 2016 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.