com.sdicons.json.serializer.marshall
Class JSONMarshall

java.lang.Object
  extended by com.sdicons.json.serializer.marshall.JSONMarshall
All Implemented Interfaces:
Marshall

public class JSONMarshall
extends Object
implements Marshall


Field Summary
static String ERR_MISSINGATTR
           
static String ERR_MISSINGATTRVAL
           
static String ERR_MISSINGSTRING
           
static String RNDR_ARR
           
static String RNDR_ATTR_CLASS
           
static String RNDR_ATTR_ID
           
static String RNDR_ATTR_KIND
           
static String RNDR_ATTR_REF
           
static String RNDR_ATTR_TYPE
           
static String RNDR_ATTR_VALUE
           
static String RNDR_NULL
           
static String RNDR_OBJ
           
static String RNDR_OBJREF
           
static String RNDR_PRIM
           
static String RNDR_PRTITYP_BOOLEAN
           
static String RNDR_PRTITYP_BYTE
           
static String RNDR_PRTITYP_CHAR
           
static String RNDR_PRTITYP_DOUBLE
           
static String RNDR_PRTITYP_FLOAT
           
static String RNDR_PRTITYP_INT
           
static String RNDR_PRTITYP_LONG
           
static String RNDR_PRTITYP_SHORT
           
 
Constructor Summary
JSONMarshall()
           
 
Method Summary
 void addHelper(MarshallHelper aHelper)
          Add custom helper class.
 JSONObject marshall(boolean aValue)
          Convert a boolean primitive to JSON.
 JSONObject marshall(byte aValue)
          Convert a byte primitive to JSON.
 JSONObject marshall(char aValue)
          Convert a char primitive to JSON.
 JSONObject marshall(double aValue)
          Convert a double primitive to JSON.
 JSONObject marshall(float aValue)
          Convert a float primitive to JSON.
 JSONObject marshall(int aValue)
          Convert an int primitive to JSON.
 JSONObject marshall(long aValue)
          Convert a long primitive to JSON.
 JSONObject marshall(Object aObj)
          Convert a Java object to JSON.
 JSONObject marshall(short aValue)
          Convert a short primitive to JSON.
 JSONObject marshallImpl(Object aObj, HashMap aPool)
           
static void requireStringAttribute(JSONObject aElement, String anAttribute)
           
 MarshallValue unmarshall(JSONObject aElement)
          Convert a JSON representation to the Java primitive or reference.
 Object unmarshallImpl(JSONObject aElement, HashMap aObjectPool)
           
 void useJavaBeanAccess()
          The objects that fall back on the general object helper will be serialized by using their JavaBean properties.
 void usePojoAccess()
          The objects that fall back on the general object helper will be serialized by using their fields directly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RNDR_NULL

public static final String RNDR_NULL
See Also:
Constant Field Values

RNDR_OBJ

public static final String RNDR_OBJ
See Also:
Constant Field Values

RNDR_OBJREF

public static final String RNDR_OBJREF
See Also:
Constant Field Values

RNDR_PRIM

public static final String RNDR_PRIM
See Also:
Constant Field Values

RNDR_ARR

public static final String RNDR_ARR
See Also:
Constant Field Values

RNDR_ATTR_ID

public static final String RNDR_ATTR_ID
See Also:
Constant Field Values

RNDR_ATTR_KIND

public static final String RNDR_ATTR_KIND
See Also:
Constant Field Values

RNDR_ATTR_TYPE

public static final String RNDR_ATTR_TYPE
See Also:
Constant Field Values

RNDR_ATTR_VALUE

public static final String RNDR_ATTR_VALUE
See Also:
Constant Field Values

RNDR_ATTR_CLASS

public static final String RNDR_ATTR_CLASS
See Also:
Constant Field Values

RNDR_ATTR_REF

public static final String RNDR_ATTR_REF
See Also:
Constant Field Values

RNDR_PRTITYP_BOOLEAN

public static final String RNDR_PRTITYP_BOOLEAN
See Also:
Constant Field Values

RNDR_PRTITYP_BYTE

public static final String RNDR_PRTITYP_BYTE
See Also:
Constant Field Values

RNDR_PRTITYP_CHAR

public static final String RNDR_PRTITYP_CHAR
See Also:
Constant Field Values

RNDR_PRTITYP_SHORT

public static final String RNDR_PRTITYP_SHORT
See Also:
Constant Field Values

RNDR_PRTITYP_INT

public static final String RNDR_PRTITYP_INT
See Also:
Constant Field Values

RNDR_PRTITYP_LONG

public static final String RNDR_PRTITYP_LONG
See Also:
Constant Field Values

RNDR_PRTITYP_FLOAT

public static final String RNDR_PRTITYP_FLOAT
See Also:
Constant Field Values

RNDR_PRTITYP_DOUBLE

public static final String RNDR_PRTITYP_DOUBLE
See Also:
Constant Field Values

ERR_MISSINGATTR

public static final String ERR_MISSINGATTR
See Also:
Constant Field Values

ERR_MISSINGATTRVAL

public static final String ERR_MISSINGATTRVAL
See Also:
Constant Field Values

ERR_MISSINGSTRING

public static final String ERR_MISSINGSTRING
See Also:
Constant Field Values
Constructor Detail

JSONMarshall

public JSONMarshall()
Method Detail

marshall

public JSONObject marshall(boolean aValue)
Description copied from interface: Marshall
Convert a boolean primitive to JSON.

Specified by:
marshall in interface Marshall
Returns:
An JSON representation of the boolean primitive.

marshall

public JSONObject marshall(byte aValue)
Description copied from interface: Marshall
Convert a byte primitive to JSON.

Specified by:
marshall in interface Marshall
Returns:
An JSON representation of the byte primitive.

marshall

public JSONObject marshall(short aValue)
Description copied from interface: Marshall
Convert a short primitive to JSON.

Specified by:
marshall in interface Marshall
Returns:
An JSON representation of the short primitive.

marshall

public JSONObject marshall(char aValue)
Description copied from interface: Marshall
Convert a char primitive to JSON.

Specified by:
marshall in interface Marshall
Returns:
An JSON representation of the char primitive.

marshall

public JSONObject marshall(int aValue)
Description copied from interface: Marshall
Convert an int primitive to JSON.

Specified by:
marshall in interface Marshall
Returns:
An JSON representation of the int primitive.

marshall

public JSONObject marshall(long aValue)
Description copied from interface: Marshall
Convert a long primitive to JSON.

Specified by:
marshall in interface Marshall
Returns:
An JSON representation of the long primitive.

marshall

public JSONObject marshall(float aValue)
Description copied from interface: Marshall
Convert a float primitive to JSON.

Specified by:
marshall in interface Marshall
Returns:
An JSON representation of the float primitive.

marshall

public JSONObject marshall(double aValue)
Description copied from interface: Marshall
Convert a double primitive to JSON.

Specified by:
marshall in interface Marshall
Returns:
An JSON representation of the double primitive.

marshall

public JSONObject marshall(Object aObj)
                    throws MarshallException
Description copied from interface: Marshall
Convert a Java object to JSON.

Specified by:
marshall in interface Marshall
Returns:
The JSON representation of the Java object.
Throws:
MarshallException - An error occured while converting the Java object to JSON.

marshallImpl

public JSONObject marshallImpl(Object aObj,
                               HashMap aPool)
                        throws MarshallException
Throws:
MarshallException

unmarshall

public MarshallValue unmarshall(JSONObject aElement)
                         throws MarshallException
Description copied from interface: Marshall
Convert a JSON representation to the Java primitive or reference.

Specified by:
unmarshall in interface Marshall
Returns:
The Java representation of the JSON. This value can represent a Java primitive value or it can represent a Java reference.
Throws:
MarshallException - An error occured while trying to convert the JSON representation into a Java representation.

unmarshallImpl

public Object unmarshallImpl(JSONObject aElement,
                             HashMap aObjectPool)
                      throws MarshallException
Throws:
MarshallException

requireStringAttribute

public static void requireStringAttribute(JSONObject aElement,
                                          String anAttribute)
                                   throws MarshallException
Throws:
MarshallException

addHelper

public void addHelper(MarshallHelper aHelper)
Add custom helper class.

Parameters:
aHelper - the custom helper you want to add to the serializer.

usePojoAccess

public void usePojoAccess()
The objects that fall back on the general object helper will be serialized by using their fields directly. Without further annotations, the default constructor without arguments will be used in the POJO. If this is not sufficient, the @JSONConstruct and @JSONSerialize annotations can be used as well in the POJO to indicate which constructor has to be used.


useJavaBeanAccess

public void useJavaBeanAccess()
The objects that fall back on the general object helper will be serialized by using their JavaBean properties. The JavaBean always needs a default constructor without arguments.



Copyright © 2011. All Rights Reserved.