ikrs.json.parser
Class DefaultJSONValueFactory

java.lang.Object
  extended by ikrs.json.parser.DefaultJSONValueFactory
All Implemented Interfaces:
JSONValueFactory
Direct Known Subclasses:
JSONRPCValueFactory

public class DefaultJSONValueFactory
extends java.lang.Object
implements JSONValueFactory

A default JSONValueFactory implementation which is meant to be subclassed. All methods just create new JSONValues, except createNull(...) which returns JSONValue.NULL: - createArray(...) returns 'new JSONArray()' - createNumber(...) returns 'new JSONumber(...)' - createBoolean(...) returns 'new JSONBoolean(...)' - ... and so on ...


Constructor Summary
DefaultJSONValueFactory()
          Creates a new default JSONValueFactory.
 
Method Summary
 JSONArray createArray()
          This method creates a non-embedded JSON array (first single value from the input).
 JSONArray createArray(int arrayIndex)
          This method creates a JSON array embedded inside a different JSON array.
 JSONArray createArray(java.lang.String memberName)
          This method creates a JSON array embedded inside a different JSON object.
 JSONBoolean createBoolean(java.lang.Boolean bool)
          This method creates a non-embedded JSON boolean (first single value from the input).
 JSONBoolean createBoolean(java.lang.Boolean bool, int arrayIndex)
          This method creates a JSON boolean embedded inside a JSON array.
 JSONBoolean createBoolean(java.lang.Boolean bool, java.lang.String memberName)
          This method creates a JSON boolean embedded inside a JSON object.
 JSONNull createNull()
          This method creates a non-embedded JSON null (first single value from the input).
 JSONNull createNull(int arrayIndex)
          This method creates a JSON null embedded inside a JSON array.
 JSONNull createNull(java.lang.String memberName)
          This method creates a JSON null embedded inside a JSON object.
 JSONNumber createNumber(java.lang.Number number)
          This method creates a non-embedded JSON number (first single value from the input).
 JSONNumber createNumber(java.lang.Number number, int arrayIndex)
          This method creates a JSON number embedded inside a JSON array.
 JSONNumber createNumber(java.lang.Number number, java.lang.String memberName)
          This method creates a JSON number embedded inside a JSON object.
 JSONObject createObject()
          This method creates a non-embedded JSON object (first single value from the input).
 JSONObject createObject(int arraIndex)
          This method creates a JSON object embedded inside a different JSON object.
 JSONObject createObject(java.lang.String memberName)
          This method creates a JSON object embedded inside a different JSON object.
 JSONString createString(java.lang.String str)
          This method creates a non-embedded JSON string (first single value from the input).
 JSONString createString(java.lang.String str, int arrayIndex)
          This method creates a JSON string embedded inside a JSON array.
 JSONString createString(java.lang.String str, java.lang.String memberName)
          This method creates a JSON string embedded inside a JSON object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultJSONValueFactory

public DefaultJSONValueFactory()
Creates a new default JSONValueFactory.

Method Detail

createNumber

public JSONNumber createNumber(java.lang.Number number)
This method creates a non-embedded JSON number (first single value from the input).

Specified by:
createNumber in interface JSONValueFactory
Returns:
A single JSON number.

createNumber

public JSONNumber createNumber(java.lang.Number number,
                               int arrayIndex)
This method creates a JSON number embedded inside a JSON array. The passed integer is the element's array index.

Specified by:
createNumber in interface JSONValueFactory
Parameters:
arrayIndex - The superior array's index where the new element is located.
Returns:
A JSON number inside a different array.

createNumber

public JSONNumber createNumber(java.lang.Number number,
                               java.lang.String memberName)
This method creates a JSON number embedded inside a JSON object. The passed string is the element's member name.

Specified by:
createNumber in interface JSONValueFactory
Parameters:
memberName - The new number's member name inside the superior object.
Returns:
A JSON number inside a object.

createBoolean

public JSONBoolean createBoolean(java.lang.Boolean bool)
This method creates a non-embedded JSON boolean (first single value from the input).

Specified by:
createBoolean in interface JSONValueFactory
Returns:
A single JSON bolean.

createBoolean

public JSONBoolean createBoolean(java.lang.Boolean bool,
                                 int arrayIndex)
This method creates a JSON boolean embedded inside a JSON array. The passed integer is the element's array index.

Specified by:
createBoolean in interface JSONValueFactory
Parameters:
arrayIndex - The superior array's index where the new element is located.
Returns:
A JSON boolean inside an array.

createBoolean

public JSONBoolean createBoolean(java.lang.Boolean bool,
                                 java.lang.String memberName)
This method creates a JSON boolean embedded inside a JSON object. The passed string is the element's member name.

Specified by:
createBoolean in interface JSONValueFactory
Parameters:
memberName - The new boolean's member name inside the superior object.
Returns:
A JSON boolean inside a object.

createString

public JSONString createString(java.lang.String str)
This method creates a non-embedded JSON string (first single value from the input).

Specified by:
createString in interface JSONValueFactory
Returns:
A single JSON string.

createString

public JSONString createString(java.lang.String str,
                               int arrayIndex)
This method creates a JSON string embedded inside a JSON array. The passed integer is the element's array index.

Specified by:
createString in interface JSONValueFactory
Parameters:
arrayIndex - The superior array's index where the new element is located.
Returns:
A JSON string inside an array.

createString

public JSONString createString(java.lang.String str,
                               java.lang.String memberName)
This method creates a JSON string embedded inside a JSON object. The passed string is the element's member name.

Specified by:
createString in interface JSONValueFactory
Parameters:
memberName - The new boolean's member name inside the superior object.
Returns:
A JSON string inside a object.

createNull

public JSONNull createNull()
This method creates a non-embedded JSON null (first single value from the input).

Specified by:
createNull in interface JSONValueFactory
Returns:
A single JSON null.

createNull

public JSONNull createNull(int arrayIndex)
This method creates a JSON null embedded inside a JSON array. The passed integer is the element's array index.

Specified by:
createNull in interface JSONValueFactory
Parameters:
arrayIndex - The superior array's index where the new element is located.
Returns:
A JSON null inside an array.

createNull

public JSONNull createNull(java.lang.String memberName)
This method creates a JSON null embedded inside a JSON object. The passed string is the element's member name.

Specified by:
createNull in interface JSONValueFactory
Parameters:
memberName - The new null's member name inside the superior object.
Returns:
A JSON null inside a object.

createArray

public JSONArray createArray()
This method creates a non-embedded JSON array (first single value from the input).

Specified by:
createArray in interface JSONValueFactory
Returns:
A single JSON array.

createArray

public JSONArray createArray(int arrayIndex)
This method creates a JSON array embedded inside a different JSON array. The passed integer is the element's array index.

Specified by:
createArray in interface JSONValueFactory
Parameters:
arrayIndex - The superior array's index where the new element is located.
Returns:
A JSON array inside a different array.

createArray

public JSONArray createArray(java.lang.String memberName)
This method creates a JSON array embedded inside a different JSON object. The passed string is the element's member name.

Specified by:
createArray in interface JSONValueFactory
Parameters:
memberName - The new array's member name inside the superior object.
Returns:
A JSON array inside a object.

createObject

public JSONObject createObject()
This method creates a non-embedded JSON object (first single value from the input).

Specified by:
createObject in interface JSONValueFactory
Returns:
A single JSON object.

createObject

public JSONObject createObject(int arraIndex)
This method creates a JSON object embedded inside a different JSON object. The passed integer is the element's array index.

Specified by:
createObject in interface JSONValueFactory
Parameters:
arrayIndex - The superior array's index where the new element is located.
Returns:
A JSON object inside an array.

createObject

public JSONObject createObject(java.lang.String memberName)
This method creates a JSON object embedded inside a different JSON object. The passed string is the element's member name.

Specified by:
createObject in interface JSONValueFactory
Parameters:
memberName - The new object's member name inside the superior object.
Returns:
A JSON object inside a different object.