org.inria.ns.reflex.xml.json
Class Handler

java.lang.Object
  extended by org.inria.ns.reflex.xml.json.Handler
All Implemented Interfaces:
JSONHandler

public class Handler
extends Object
implements JSONHandler

XML handler for XML-aware JSON objects.

Author:
Philippe Poulard
See Also:
Factory

Constructor Summary
Handler()
           
 
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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Handler

public Handler()
Method Detail

addJSONComment

public void addJSONComment(JSONContext context)
Add a JSON comment to the current structure ; effects may vary according to the configuration in use.

This method is called by the parser when it has read a JSON comment (which is hold by this context).

Specified by:
addJSONComment in interface JSONHandler
Parameters:
context - The context that hold the parser state and structure.
See Also:
JSONFactory#newJSONComment(JSONParser, String), JSONConfiguration

addJSONMember

public 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.

This method is called by the parser when it has read a JSON member (which is hold by this context).

Specified by:
addJSONMember in interface JSONHandler
Parameters:
context - The context that hold the parser state and structure.
name - The name of the member, usually it is a simple wrapped string, but custom XML names can be considered.
Returns:
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.
See Also:
JSONFactory#newJSONMember(JSONParser, QName, Object), JSONConfiguration

addJSONValue

public boolean addJSONValue(JSONContext context)
Add a JSON value to the current structure ; effects may vary according to the configuration in use.

This method is called by the parser when it has read a JSON value (which is hold by this context).

Specified by:
addJSONValue in interface JSONHandler
Parameters:
context - The context that hold the parser state and structure.
Returns:
false if the configuration indicates to attach objects to parents and the value is a JSON object and is not the root structure, true otherwise.
See Also:
JSONFactory, JSONConfiguration, Configuration.isAttachObjectsToParent()