|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface JSONHandler
The methods of this interface are called by the parser when a comment, a value, or a member (a pair of name-value) have to be inserted in the structure hold in the given context. Therefore, the JSON handler is responsible of the creation of the target structure. A concrete implementation should populate JSON arrays, objects and documents with the values, members, and optionally comments if they are supported.
According to the configuration in use (available in the context), various behaviour can be considered.
Get the item to add with JSONContext.lastValue()
(it will be an item built by the JSON factory in use).
Add it to the current structure JSONContext.peekStructure().
Additional methods are available to check the type of the item to add (JSONContext#lastIsXXX) and the type of the host structure (JSONContext#hostIsXXX).
With those informations and according to the configuration,
an item can be added as an attribute, an element, or skipped.
In this last case, the method MUST notify the parser that a
structure (object or array) was skipped by returning false.
JSONContext,
JSONFactory| Method Summary | |
|---|---|
void |
addJSONComment(JSONContext context)
Add a JSON comment to the current structure ; effects may vary according to the configuration in use. |
boolean |
addJSONMember(JSONContext context,
QName name)
Add a JSON member (that is to say a name/value pair) to the current structure ; effects may vary according to the configuration in use. |
boolean |
addJSONValue(JSONContext context)
Add a JSON value to the current structure ; effects may vary according to the configuration in use. |
| Method Detail |
|---|
void addJSONComment(JSONContext context)
This method is called by the parser when it has read a JSON comment (which is hold by the given context).
context - The context that hold the parser state and structure.JSONFactory.newJSONComment(JSONContext, String),
JSONConfiguration
boolean addJSONMember(JSONContext context,
QName name)
This method is called by the parser when it has read a JSON member (which is hold by the given context).
context - The context that hold the parser state and structure,
and the value to add.name - The name of the member, usually it is a simple wrapped string,
but custom XML names can be considered.
true to indicate to the parser that
the member was effectively added to the target structure,
false otherwise. This allow to skip unwanted
structures safely.JSONFactory,
JSONConfigurationboolean addJSONValue(JSONContext context)
This method is called by the parser when it has read a JSON value (which is hold by the given context).
context - The context that hold the parser state and structure
and the value to add.
true to indicate to the parser that
the member was effectively added to the target structure,
false otherwise. This allow to skip unwanted
structures safely.JSONFactory,
JSONConfiguration
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||