OA
- the JSON object accumulator typeAA
- the JSON array accumulator typeOR
- the JSON object result typeAR
- the JSON array result typepublic interface StructureCollector<OA,AA,OR,AR>
JSONLimitBuilder
to parameterize the creation and population
of object and array structures, null
values, and creation of
a "finished" result type. Similar to Collector
in Java 8's stream
package.
For instance, structures may be created as JSONObject
and
JSONArray
, with JSONObject.NULL
for JSON null. Another
collector may create structures as HashMap
and ArrayList
, and
Java's null
value for JSON null.
Modifier and Type | Method and Description |
---|---|
void |
addNull(AA array)
Adds a JSON null value to the given JSON array accumulator.
|
void |
addNull(OA object,
java.lang.String key)
Adds a JSON null entry to the given JSON object.
|
void |
addValue(AA array,
java.lang.Object value)
Adds the given value to the given JSON array accumulator.
|
void |
addValue(OA object,
java.lang.String key,
java.lang.Object value)
Adds the given entry to the given JSON object.
|
AA |
createArrayAccumulator()
Create an instance of an object into which JSON array entries are
added.
|
OA |
createObjectAccumulator()
Create an instance of an object into which JSON object entries are
added.
|
AR |
finishArray(AA accumulator)
Finish the given JSON array accumulator, returning the array result.
|
OR |
finishObject(OA accumulator)
Finish the given JSON object accumulator, returning the object result.
|
java.lang.Object |
nullValue()
Provide a null value for circumstances where JSON null is the complete
result of a JSON parse.
|
OA createObjectAccumulator()
void addValue(OA object, java.lang.String key, java.lang.Object value) throws JSONException
object
- the JSON object accumulator to which the entry will be addedkey
- the key of the entryvalue
- the value of the entryJSONException
- may be thrown if a duplicate key is encounteredvoid addNull(OA object, java.lang.String key) throws JSONException
object
- the JSON object accumulator to which the entry will be addedkey
- the key of the entryJSONException
- may be thrown if a duplicate key is encounteredOR finishObject(OA accumulator) throws JSONException
accumulator
- the JSON object accumulator to be finishedJSONException
- there was a problem finishing the objectAA createArrayAccumulator()
void addValue(AA array, java.lang.Object value) throws JSONException
array
- the JSON array accumulator to which the value will be addedvalue
- the value to be addedJSONException
void addNull(AA array) throws JSONException
array
- the JSON array accumulator to which the null value
will be addedJSONException
AR finishArray(AA accumulator) throws JSONException
accumulator
- the JSON array accumulator to be finishedJSONException
- there was a problem finishing the arrayjava.lang.Object nullValue()