com.ibm.commons.util.io.json
Class JsonJavaFactory

java.lang.Object
  extended by com.ibm.commons.util.io.json.JsonJavaFactory
All Implemented Interfaces:
JsonFactory

public class JsonJavaFactory
extends java.lang.Object
implements JsonFactory

This factory is used manipulate Java object.

The values are mapped by Java objects (String, Number, List, Map...). Note that the collections can either be Map or JsonJavaObject.


Field Summary
static JsonJavaFactory instance
          Singleton instance that uses java.util.Map for collection.
static JsonJavaFactory instanceEx
          Singleton instance that uses JsonJavaObject for collection.
static JsonJavaFactory instanceEx2
           
static JsonJavaFactory instanceExI
           
 
Fields inherited from interface com.ibm.commons.util.io.json.JsonFactory
FEATURE_INLINEJAVASCRIPT
 
Constructor Summary
JsonJavaFactory()
           
 
Method Summary
 java.lang.Object createArray(java.lang.Object parent, java.lang.String propertyName, java.util.List<java.lang.Object> values)
           
 java.lang.Object createBoolean(boolean value)
           
 java.lang.Object createJavaScriptCode(java.lang.String code)
           
 java.lang.Object createNull()
           
 java.lang.Object createNumber(double value)
           
 java.lang.Object createObject(java.lang.Object parent, java.lang.String propertyName)
           
 java.lang.Object createString(java.lang.String value)
           
 java.util.List<java.lang.Object> createTemporaryArray(java.lang.Object parent)
           
 java.lang.Object createUndefined()
           
 int getArrayCount(java.lang.Object value)
           
 java.lang.Object getArrayItem(java.lang.Object value, int index)
           
 boolean getBoolean(java.lang.Object value)
           
 java.lang.String getJavaScriptCode(java.lang.Object value)
           
 double getNumber(java.lang.Object value)
           
 java.lang.Object getProperty(java.lang.Object parent, java.lang.String propertyName)
           
 java.lang.String getString(java.lang.Object value)
           
 boolean isArray(java.lang.Object value)
           
 boolean isBoolean(java.lang.Object value)
           
 boolean isJavaScriptCode(java.lang.Object value)
           
 boolean isNull(java.lang.Object value)
           
 boolean isNumber(java.lang.Object value)
           
 boolean isObject(java.lang.Object value)
           
 boolean isString(java.lang.Object value)
           
 boolean isUndefined(java.lang.Object value)
           
 boolean isValidValue(java.lang.Object value)
           
 java.util.Iterator<java.lang.Object> iterateArrayValues(java.lang.Object array)
           
 java.util.Iterator<java.lang.String> iterateObjectProperties(java.lang.Object object)
           
 void setProperty(java.lang.Object parent, java.lang.String propertyName, java.lang.Object value)
           
 boolean supportFeature(int feature)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static final JsonJavaFactory instance
Singleton instance that uses java.util.Map for collection.


instanceEx

public static final JsonJavaFactory instanceEx
Singleton instance that uses JsonJavaObject for collection.


instanceEx2

public static final JsonJavaFactory instanceEx2

instanceExI

public static final JsonJavaFactory instanceExI
Constructor Detail

JsonJavaFactory

public JsonJavaFactory()
Method Detail

supportFeature

public boolean supportFeature(int feature)
Specified by:
supportFeature in interface JsonFactory

isValidValue

public boolean isValidValue(java.lang.Object value)
                     throws JsonException
Specified by:
isValidValue in interface JsonFactory
Throws:
JsonException

createNull

public java.lang.Object createNull()
                            throws JsonException
Specified by:
createNull in interface JsonFactory
Throws:
JsonException

createUndefined

public java.lang.Object createUndefined()
                                 throws JsonException
Specified by:
createUndefined in interface JsonFactory
Throws:
JsonException

createString

public java.lang.Object createString(java.lang.String value)
                              throws JsonException
Specified by:
createString in interface JsonFactory
Throws:
JsonException

createNumber

public java.lang.Object createNumber(double value)
                              throws JsonException
Specified by:
createNumber in interface JsonFactory
Throws:
JsonException

createBoolean

public java.lang.Object createBoolean(boolean value)
                               throws JsonException
Specified by:
createBoolean in interface JsonFactory
Throws:
JsonException

createObject

public java.lang.Object createObject(java.lang.Object parent,
                                     java.lang.String propertyName)
                              throws JsonException
Specified by:
createObject in interface JsonFactory
Throws:
JsonException

createArray

public java.lang.Object createArray(java.lang.Object parent,
                                    java.lang.String propertyName,
                                    java.util.List<java.lang.Object> values)
                             throws JsonException
Specified by:
createArray in interface JsonFactory
Throws:
JsonException

createJavaScriptCode

public java.lang.Object createJavaScriptCode(java.lang.String code)
                                      throws JsonException
Specified by:
createJavaScriptCode in interface JsonFactory
Throws:
JsonException

setProperty

public void setProperty(java.lang.Object parent,
                        java.lang.String propertyName,
                        java.lang.Object value)
                 throws JsonException
Specified by:
setProperty in interface JsonFactory
Throws:
JsonException

getProperty

public java.lang.Object getProperty(java.lang.Object parent,
                                    java.lang.String propertyName)
                             throws JsonException
Specified by:
getProperty in interface JsonFactory
Throws:
JsonException

isNull

public boolean isNull(java.lang.Object value)
               throws JsonException
Specified by:
isNull in interface JsonFactory
Throws:
JsonException

isUndefined

public boolean isUndefined(java.lang.Object value)
Specified by:
isUndefined in interface JsonFactory

isString

public boolean isString(java.lang.Object value)
                 throws JsonException
Specified by:
isString in interface JsonFactory
Throws:
JsonException

getString

public java.lang.String getString(java.lang.Object value)
                           throws JsonException
Specified by:
getString in interface JsonFactory
Throws:
JsonException

isNumber

public boolean isNumber(java.lang.Object value)
                 throws JsonException
Specified by:
isNumber in interface JsonFactory
Throws:
JsonException

getNumber

public double getNumber(java.lang.Object value)
                 throws JsonException
Specified by:
getNumber in interface JsonFactory
Throws:
JsonException

isBoolean

public boolean isBoolean(java.lang.Object value)
                  throws JsonException
Specified by:
isBoolean in interface JsonFactory
Throws:
JsonException

getBoolean

public boolean getBoolean(java.lang.Object value)
                   throws JsonException
Specified by:
getBoolean in interface JsonFactory
Throws:
JsonException

isObject

public boolean isObject(java.lang.Object value)
                 throws JsonException
Specified by:
isObject in interface JsonFactory
Throws:
JsonException

isJavaScriptCode

public boolean isJavaScriptCode(java.lang.Object value)
                         throws JsonException
Specified by:
isJavaScriptCode in interface JsonFactory
Throws:
JsonException

getJavaScriptCode

public java.lang.String getJavaScriptCode(java.lang.Object value)
                                   throws JsonException
Specified by:
getJavaScriptCode in interface JsonFactory
Throws:
JsonException

iterateObjectProperties

public java.util.Iterator<java.lang.String> iterateObjectProperties(java.lang.Object object)
                                                             throws JsonException
Specified by:
iterateObjectProperties in interface JsonFactory
Throws:
JsonException

isArray

public boolean isArray(java.lang.Object value)
                throws JsonException
Specified by:
isArray in interface JsonFactory
Throws:
JsonException

getArrayCount

public int getArrayCount(java.lang.Object value)
                  throws JsonException
Specified by:
getArrayCount in interface JsonFactory
Throws:
JsonException

getArrayItem

public java.lang.Object getArrayItem(java.lang.Object value,
                                     int index)
                              throws JsonException
Throws:
JsonException

iterateArrayValues

public java.util.Iterator<java.lang.Object> iterateArrayValues(java.lang.Object array)
                                                        throws JsonException
Specified by:
iterateArrayValues in interface JsonFactory
Throws:
JsonException

createTemporaryArray

public java.util.List<java.lang.Object> createTemporaryArray(java.lang.Object parent)
                                                      throws JsonException
Specified by:
createTemporaryArray in interface JsonFactory
Throws:
JsonException