com.metaparadigm.jsonrpc.serializer.impl
Class BeanSerializer

java.lang.Object
  extended by com.metaparadigm.jsonrpc.serializer.AbstractSerializer
      extended by com.metaparadigm.jsonrpc.serializer.impl.BeanSerializer
All Implemented Interfaces:
Serializer, java.io.Serializable

public class BeanSerializer
extends AbstractSerializer

See Also:
Serialized Form

Nested Class Summary
static class BeanSerializer.BeanSerializerState
           
 
Constructor Summary
BeanSerializer()
           
 
Method Summary
static com.metaparadigm.jsonrpc.serializer.impl.BeanSerializer.BeanData analyzeBean(java.lang.Class clazz)
           
 boolean canSerialize(java.lang.Class clazz, java.lang.Class jsonClazz)
          Default check that simply tests the given serializeable class arrays to determine if the pair of classes can be serialized/deserialized from this Serializer.
static com.metaparadigm.jsonrpc.serializer.impl.BeanSerializer.BeanData getBeanData(java.lang.Class clazz)
           
 java.lang.Class[] getJSONClasses()
          Get the json java classes that this Serializer is able to serialize from json into java and deserialize into json from java.
 java.lang.Class[] getSerializableClasses()
          Get the java classes that this Serializer is able to serialize from java into json and deserialize into java from json.
 java.lang.Object marshall(SerializerState state, java.lang.Object o)
          Marshall a java object into an equivalent json object.
 ObjectMatch tryUnmarshall(SerializerState state, java.lang.Class clazz, java.lang.Object o)
           
 java.lang.Object unmarshall(SerializerState state, java.lang.Class clazz, java.lang.Object o)
          Unmarshall json into an equivalent java object.
 
Methods inherited from class com.metaparadigm.jsonrpc.serializer.AbstractSerializer
setOwner
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanSerializer

public BeanSerializer()
Method Detail

analyzeBean

public static com.metaparadigm.jsonrpc.serializer.impl.BeanSerializer.BeanData analyzeBean(java.lang.Class clazz)
                                                                                    throws java.beans.IntrospectionException
Throws:
java.beans.IntrospectionException

canSerialize

public boolean canSerialize(java.lang.Class clazz,
                            java.lang.Class jsonClazz)
Description copied from class: AbstractSerializer
Default check that simply tests the given serializeable class arrays to determine if the pair of classes can be serialized/deserialized from this Serializer.

Specified by:
canSerialize in interface Serializer
Overrides:
canSerialize in class AbstractSerializer
Parameters:
clazz - java type to check if this Serializer can handle.
jsonClazz - json type to check this Serializer can handle.
Returns:
true if this Serializer can serialize/deserialize the given java,json pair.

getBeanData

public static com.metaparadigm.jsonrpc.serializer.impl.BeanSerializer.BeanData getBeanData(java.lang.Class clazz)
                                                                                    throws java.beans.IntrospectionException
Throws:
java.beans.IntrospectionException

getJSONClasses

public java.lang.Class[] getJSONClasses()
Description copied from interface: Serializer
Get the json java classes that this Serializer is able to serialize from json into java and deserialize into json from java. These will typically be primitive class type wrappers or JSONObject, JSONArray.

Returns:
json side java classes that can be serialized/deserialized by this serializer.

getSerializableClasses

public java.lang.Class[] getSerializableClasses()
Description copied from interface: Serializer
Get the java classes that this Serializer is able to serialize from java into json and deserialize into java from json.

Returns:
java side classes that can be serialized/deserialized by this serializer.

marshall

public java.lang.Object marshall(SerializerState state,
                                 java.lang.Object o)
                          throws MarshallException
Description copied from interface: Serializer
Marshall a java object into an equivalent json object.

Parameters:
state - can be used to hold state while unmarshalling through recursive levels.
o - java object to marhsall into json.
Returns:
that JSONObject or JSONArray that contains the json representation of the java object that was marshalled.
Throws:
MarshallException - if there is a problem marshalling java to json.

tryUnmarshall

public ObjectMatch tryUnmarshall(SerializerState state,
                                 java.lang.Class clazz,
                                 java.lang.Object o)
                          throws UnmarshallException
Throws:
UnmarshallException

unmarshall

public java.lang.Object unmarshall(SerializerState state,
                                   java.lang.Class clazz,
                                   java.lang.Object o)
                            throws UnmarshallException
Description copied from interface: Serializer
Unmarshall json into an equivalent java object.

Parameters:
state - can be used to hold state while unmarshalling through recursive levels.
clazz - optional java class to unmarshall to.
o - JSONObject or JSONArray that contains the json to unmarshall.
Returns:
the java object representing the json that was unmarshalled.
Throws:
UnmarshallException - if there is a problem unmarshalling json to java.


Copyright © 2005 Metaparadigm Pte Ltd.