A
- The type of handlers used for JSON arraysO
- The type of handlers used for JSON objectspublic abstract class JsonHandler<A,O> extends Object
JsonParser
. The
parser will then call the methods of the given handler while reading the input.
The default implementations of these methods do nothing. Subclasses may override only those
methods they are interested in. They can use getLocation()
to access the current
character position of the parser at any point. The start*
methods will be called
while the location points to the first character of the parsed element. The end*
methods will be called while the location points to the character position that directly follows
the last character of the parsed element. Example:
["lorem ipsum"] ^ ^ startString endString
Subclasses that build an object representation of the parsed JSON can return arbitrary handler
objects for JSON arrays and JSON objects in startArray()
and startObject()
.
These handler objects will then be provided in all subsequent parser events for this particular
array or object. They can be used to keep track the elements of a JSON array or object.
JsonParser
Constructor and Description |
---|
JsonHandler() |
Modifier and Type | Method and Description |
---|---|
void |
endArray(A array)
Indicates the end of an array in the JSON input.
|
void |
endArrayValue(A array)
Indicates the end of an array element in the JSON input.
|
void |
endBoolean(boolean value)
Indicates the end of a boolean literal (
true or false ) in the JSON
input. |
void |
endNull()
Indicates the end of a
null literal in the JSON input. |
void |
endNumber(String string)
Indicates the end of a number in the JSON input.
|
void |
endObject(O object)
Indicates the end of an object in the JSON input.
|
void |
endObjectName(O object,
String name)
Indicates the end of an object member name in the JSON input.
|
void |
endObjectValue(O object,
String name)
Indicates the end of an object member value in the JSON input.
|
void |
endString(String string)
Indicates the end of a string in the JSON input.
|
protected Location |
getLocation()
Returns the current parser location.
|
A |
startArray()
Indicates the beginning of an array in the JSON input.
|
void |
startArrayValue(A array)
Indicates the beginning of an array element in the JSON input.
|
void |
startBoolean()
Indicates the beginning of a boolean literal (
true or false ) in the
JSON input. |
void |
startNull()
Indicates the beginning of a
null literal in the JSON input. |
void |
startNumber()
Indicates the beginning of a number in the JSON input.
|
O |
startObject()
Indicates the beginning of an object in the JSON input.
|
void |
startObjectName(O object)
Indicates the beginning of the name of an object member in the JSON input.
|
void |
startObjectValue(O object,
String name)
Indicates the beginning of the name of an object member in the JSON input.
|
void |
startString()
Indicates the beginning of a string in the JSON input.
|
protected Location getLocation()
public void startNull()
null
literal in the JSON input. This method will be
called when reading the first character of the literal.public void endNull()
null
literal in the JSON input. This method will be called
after reading the last character of the literal.public void startBoolean()
true
or false
) in the
JSON input. This method will be called when reading the first character of the literal.public void endBoolean(boolean value)
true
or false
) in the JSON
input. This method will be called after reading the last character of the literal.value
- the parsed boolean valuepublic void startString()
'"'
).public void endString(String string)
'"'
).string
- the parsed stringpublic void startNumber()
public void endNumber(String string)
string
- the parsed number stringpublic A startArray()
'['
).
This method may return an object to handle subsequent parser events for this array. This array
handler will then be provided in all calls to startArrayValue()
, endArrayValue()
, and
endArray()
for this array.
null
if not neededpublic void endArray(A array)
']'
).array
- the array handler returned from startArray()
, or null
if not
providedpublic void startArrayValue(A array)
start
method for the specific element type (startString()
, startNumber()
, etc.).array
- the array handler returned from startArray()
, or null
if not
providedpublic void endArrayValue(A array)
end
method for the
specific element type (like endString()
, endNumber()
, etc.).array
- the array handler returned from startArray()
, or null
if not
providedpublic O startObject()
'{'
).
This method may return an object to handle subsequent parser events for this object. This
object handler will be provided in all calls to startObjectName()
, endObjectName()
,
startObjectValue()
,
endObjectValue()
, and endObject()
for this object.
null
if not neededpublic void endObject(O object)
'}'
).object
- the object handler returned from startObject()
, or null if not providedpublic void startObjectName(O object)
object
- the object handler returned from startObject()
, or null
if not
providedpublic void endObjectName(O object, String name)
'"'
) of the member name.object
- the object handler returned from startObject()
, or null if not providedname
- the parsed member namepublic void startObjectValue(O object, String name)
object
- the object handler returned from startObject()
, or null
if not
providedname
- the member namepublic void endObjectValue(O object, String name)
end
method for the
specific member type (like endString()
, endNumber()
, etc.).object
- the object handler returned from startObject()
, or null if not providedname
- the parsed member nameCopyright © 2019 Hazelcast, Inc.. All Rights Reserved.