public final class DefaultJsonPullParser extends Object implements JsonPullParser
| Constructor and Description |
|---|
DefaultJsonPullParser(char[] characters)
Creates a new
DefaultJsonPullParser. |
DefaultJsonPullParser(JsonSource source)
Creates a new
DefaultJsonPullParser. |
DefaultJsonPullParser(JsonSource source,
JsonParserMode... modes)
Creates a new
DefaultJsonPullParser. |
DefaultJsonPullParser(Reader reader)
Creates a new
DefaultJsonPullParser. |
DefaultJsonPullParser(String string)
Creates a new
DefaultJsonPullParser. |
| 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. |
void |
close() |
JsonState |
currentState()
Reads, if necessary, from the underlying Reader and describes the current
JsonState of this DefaultJsonPullParser, 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 |
hasNextElement()
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.
|
String |
toString() |
public DefaultJsonPullParser(String string) throws IllegalArgumentException
DefaultJsonPullParser.string - The String to read from.IllegalArgumentException - If the given String is null.public DefaultJsonPullParser(char[] characters)
throws IllegalArgumentException
DefaultJsonPullParser.characters - The char[] to read from.IllegalArgumentException - If the given char[] is null.public DefaultJsonPullParser(Reader reader) throws IllegalArgumentException
DefaultJsonPullParser.reader - The Reader to read from.IllegalArgumentException - If the given Reader is null.public DefaultJsonPullParser(JsonSource source) throws IllegalArgumentException
DefaultJsonPullParser.source - The JsonSource to read from.IllegalArgumentException - If the given JsonSource is null.public DefaultJsonPullParser(JsonSource source, JsonParserMode... modes) throws IllegalArgumentException
DefaultJsonPullParser.source - The JsonSource to read from.modes - Selection of JsonParserModes to be used
during parsing.IllegalArgumentException - If the given JsonSource is null.public boolean hasNextElement()
throws JsonSyntaxException,
IOException
JsonPullParserhasNextElement in interface JsonPullParserJsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.public JsonState currentState() throws JsonSyntaxException, IOException
JsonPullParserJsonState of this DefaultJsonPullParser, which describes
the next type of value or structural element of the JSON document.currentState in interface JsonPullParserJsonState.JsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.public void beginDocument()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.beginDocument in interface JsonPullParserIllegalStateException - 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.public void endDocument()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
JsonState is JsonState.DOCUMENT_END and consumes the end
of the JSON document. The next JsonState will be
JsonState.SOURCE_END.
If this DefaultJsonPullParser allows multiple documents in the
same JsonSource, The next JsonState will be
JsonState.DOCUMENT_BEGIN or JsonState.SOURCE_END.
endDocument in interface JsonPullParserIllegalStateException - 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.public void beginArray()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.beginArray in interface JsonPullParserIllegalStateException - 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.public void endArray()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.endArray in interface JsonPullParserIllegalStateException - 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.public void beginObject()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
JsonState is JsonState.OBJECT_BEGIN and consumes the
beginning of a JSON object. The next JsonState describes either
the nextName() of the first value of this
JSON object or the end of this JSON object.beginObject in interface JsonPullParserIllegalStateException - 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.public void endObject()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.endObject in interface JsonPullParserIllegalStateException - 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.public void nextNull()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.nextNull in interface JsonPullParserIllegalStateException - 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.public boolean nextBoolean()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.nextBoolean in interface JsonPullParserboolean 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.public byte nextByte()
throws JsonValueException,
IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.nextByte in interface JsonPullParserbyte value.JsonValueException - 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.public char nextCharacter()
throws JsonValueException,
IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.nextCharacter in interface JsonPullParserchar value.JsonValueException - 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.public short nextShort()
throws JsonValueException,
IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.nextShort in interface JsonPullParsershort value.JsonValueException - 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.public int nextInteger()
throws JsonValueException,
IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.nextInteger in interface JsonPullParserint value.JsonValueException - 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.public long nextLong()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.nextLong in interface JsonPullParserlong 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.public float nextFloat()
throws JsonValueException,
IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.nextFloat in interface JsonPullParserfloat 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.JsonValueExceptionpublic double nextDouble()
throws IllegalStateException,
JsonSyntaxException,
IOException
JsonPullParsercurrent
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.nextDouble in interface JsonPullParserdouble 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.public String nextString() throws IllegalStateException, JsonSyntaxException, IOException
JsonPullParsercurrent
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.nextString in interface JsonPullParserIllegalStateException - 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.public Reader readString() throws IllegalStateException, JsonSyntaxException, IOException
JsonPullParsercurrent
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.
readString in interface JsonPullParserReader 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.public String nextName() throws IllegalStateException, JsonSyntaxException, IOException
JsonPullParsercurrent
JsonState is JsonState.NAME and consumes and returns the
corresponding name of a JSON object entry. The next JsonState
describes the corresponding value.nextName in interface JsonPullParserIllegalStateException - 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.public void skipValue()
throws JsonSyntaxException,
IOException
JsonPullParserJsonState describes either
the next sibling value of this JSON value or the end of surrounding JSON
array or JSON object.skipValue in interface JsonPullParserJsonSyntaxException - If the read JsonSyntaxException document contains a
syntax error.IOException - If reading from the underlying Reader failed.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic int getLine()
JsonPullParserline that corresponds to the
current position of the underlying JsonSource in the character
sequence, as if the character source was a regular file.getLine in interface JsonPullParserpublic int getColumn()
JsonPullParsercolumn that corresponds to the
current position of the underlying JsonSource in the character
sequence, as if the character source was a regular file.getColumn in interface JsonPullParserCopyright © 2016 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.