ccc.plugins.s11n.json
Class AbstractSerializer<T>

java.lang.Object
  extended by ccc.plugins.s11n.json.AbstractSerializer<T>
Type Parameters:
T - The type of object to serialize.
All Implemented Interfaces:
Serializer<T>
Direct Known Subclasses:
ResourceCriteriaSerializer

public abstract class AbstractSerializer<T>
extends java.lang.Object
implements Serializer<T>

Base class for serializers.

Author:
Civic Computing Ltd.

Constructor Summary
AbstractSerializer()
           
 
Method Summary
protected abstract  T createObject()
          Create a new instance of type T.
 T read(Json json)
          Deserialize from a representation.
 Json write(Json json, T instance)
          Serialize to representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSerializer

public AbstractSerializer()
Method Detail

read

public T read(Json json)
Deserialize from a representation.

Specified by:
read in interface Serializer<T>
Parameters:
json - The wire representation.
Returns:
The corresponding object.

createObject

protected abstract T createObject()
Create a new instance of type T.

Returns:
The newly created instance of T.

write

public Json write(Json json,
                  T instance)
Serialize to representation.

Specified by:
write in interface Serializer<T>
Parameters:
json - The wire representation.
instance - The object to serialize.
Returns:
Returns the 'json' input param if the 'instance' param is not NULL; returns NULL otherwise.


Copyright © 2010. All Rights Reserved.