org.inria.ns.reflex.util.json
Interface JSONFactory

All Known Implementing Classes:
Factory

public interface JSONFactory

A JSON factory build custom values found while parsing a JSON structure.

The JSON factory and the JSON handler MUST be compatible. Concrete implementations are designed to work together. Usually they come from the same package.

Author:
Philippe Poulard
See Also:
JSONParser, JSONConfiguration, JSONContext, JSONHandler

Method Summary
 Object newJSONArray(JSONContext context)
          Create a new JSON array.
 Object newJSONBoolean(JSONContext context, boolean value)
          Create a new JSON boolean.
 Object newJSONComment(JSONContext context, String comment)
          Create a new JSON comment.
 Object newJSONDocument(JSONContext context)
          Create a new JSON document object.
 Object newJSONNull(JSONContext context)
          Create a new JSON null value.
 Object newJSONNumber(JSONContext context, Number number)
          Create a new JSON number.
 Object newJSONObject(JSONContext context)
          Create a new JSON object.
 Object newJSONString(JSONContext context, String value)
          Create a new JSON string.
 

Method Detail

newJSONDocument

Object newJSONDocument(JSONContext context)
                       throws JSONException,
                              IOException
Create a new JSON document object. This method is called by the JSON parser that starts parsing the JSON input. According to the configuration passed to the parser, the JSON document can be either strict (and the root value have to be either a JSON array or a JSON object), or not (and several root values can be encountered).

Parameters:
context - The context that hold the parser state and structure.
Returns:
A custom JSON document.
Throws:
JSONException - When a parsing error occurs.
IOException - When an I/O error occurs.

newJSONArray

Object newJSONArray(JSONContext context)
                    throws JSONException,
                           IOException
Create a new JSON array. This method is called by the JSON parser that starts parsing a JSON array.

Parameters:
context - The context that hold the parser state and structure.
Returns:
A custom empty JSON array. The array will be filled as one goes along the parsing.
Throws:
JSONException - When a parsing error occurs.
IOException - When an I/O error occurs.

newJSONObject

Object newJSONObject(JSONContext context)
                     throws JSONException,
                            IOException
Create a new JSON object. This method is called by the JSON parser that starts parsing a JSON object.

Parameters:
context - The context that hold the parser state and structure.
Returns:
A custom empty JSON object. The object will be filled as one goes along the parsing.
Throws:
JSONException - When a parsing error occurs.
IOException - When an I/O error occurs.

newJSONString

Object newJSONString(JSONContext context,
                     String value)
                     throws JSONException,
                            IOException
Create a new JSON string. This method is called by the parser that have parsed a string.

Parameters:
context - The context that hold the parser state and structure.
value - The string value.
Returns:
A custom JSON string.
Throws:
JSONException - When a parsing error occurs.
IOException - When an I/O error occurs.

newJSONNumber

Object newJSONNumber(JSONContext context,
                     Number number)
                     throws JSONException,
                            IOException
Create a new JSON number. This method is called by the parser that have parsed a number.

Parameters:
context - The context that hold the parser state and structure.
number - The number parsed.
Returns:
A custom JSON number.
Throws:
JSONException - When a parsing error occurs.
IOException - When an I/O error occurs.
See Also:
NumberOperator.parseNumber(String)

newJSONBoolean

Object newJSONBoolean(JSONContext context,
                      boolean value)
                      throws JSONException,
                             IOException
Create a new JSON boolean. This method is called by the parser that have parsed a boolean.

Parameters:
context - The context that hold the parser state and structure.
value - The boolean value.
Returns:
A custom JSON boolean.
Throws:
JSONException - When a parsing error occurs.
IOException - When an I/O error occurs.

newJSONNull

Object newJSONNull(JSONContext context)
                   throws JSONException,
                          IOException
Create a new JSON null value. This method is called by the parser that have parsed the null value.

Parameters:
context - The context that hold the parser state and structure.
Returns:
A custom JSON null value. null is acceptable.
Throws:
JSONException - When a parsing error occurs.
IOException - When an I/O error occurs.

newJSONComment

Object newJSONComment(JSONContext context,
                      String comment)
                      throws JSONException,
                             IOException
Create a new JSON comment. This method is called by the parser that have parsed a comment if comments are allowed and the parser is configured to notify them.

Parameters:
context - The context that hold the parser state and structure.
comment - The comment.
Returns:
A custom JSON comment.
Throws:
JSONException - When a parsing error occurs.
IOException - When an I/O error occurs.
See Also:
JSONConfiguration.enableComments(boolean)