de.hpi.fgis.dude.util.data.json.auto
Class CompositeJsonSerialization<T>

java.lang.Object
  extended by de.hpi.fgis.dude.util.data.json.auto.AutoJsonSerialization<T>
      extended by de.hpi.fgis.dude.util.data.json.auto.CompositeJsonSerialization<T>
Type Parameters:
T - the class to wrap

public class CompositeJsonSerialization<T>
extends AutoJsonSerialization<T>

The json serialization support for classes.

Author:
Arvid.Heise

Constructor Summary
CompositeJsonSerialization(BoundType type)
          Initializes the serialization with the given type.
 
Method Summary
 Map<Field,CompositeJsonSerialization<?>> getComplexFields()
          Returns the complex fields of the wrapped type.
 Map<Field,Primitive<?>> getPrimitiveFields()
          Returns the primitive fields of the wrapped type.
 AutoJsonSerialization<? super T> getSuperTypeInfo()
          Returns the super type json serialization.
 T read(DuDeJsonParser<?> parser, Object currentValue)
          Creates an instance of the wrapped type and initializes the content with the json provided by the given DuDeJsonParser.
 void readFields(DuDeJsonParser<?> parser, T instance)
          Reads all non-transient fields of the jsonable to the DuDeJsonParser.
 void write(DuDeJsonGenerator generator, T jsonable)
          Writes the given instance to the specified DuDeJsonGenerator.
 void writeFields(DuDeJsonGenerator generator, Object jsonable)
          Writes all non-transient fields of the jsonable to the DuDeJsonGenerator.
 
Methods inherited from class de.hpi.fgis.dude.util.data.json.auto.AutoJsonSerialization
finishTypeSerializationRead, getRawType, getType, isInstantiable, read, readSerializedType, writeWithType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeJsonSerialization

public CompositeJsonSerialization(BoundType type)
Initializes the serialization with the given type.

Parameters:
type - the wrapped type
Method Detail

getComplexFields

public Map<Field,CompositeJsonSerialization<?>> getComplexFields()
Returns the complex fields of the wrapped type.

Returns:
the complex fields

getPrimitiveFields

public Map<Field,Primitive<?>> getPrimitiveFields()
Returns the primitive fields of the wrapped type.

Returns:
the primitive fields

getSuperTypeInfo

public AutoJsonSerialization<? super T> getSuperTypeInfo()
Returns the super type json serialization.

Returns:
the super type json serialization

read

public T read(DuDeJsonParser<?> parser,
              Object currentValue)
       throws org.codehaus.jackson.JsonParseException,
              IOException
Creates an instance of the wrapped type and initializes the content with the json provided by the given DuDeJsonParser. This method might reuse the currentValue but should in most cases use the actual type information of the currentValue to create a new instance.

Specified by:
read in class AutoJsonSerialization<T>
Parameters:
parser - the parser to read from
currentValue - the current value of the field which should be populated by the result of this method or null if this is the root object
Returns:
an instance of T
Throws:
org.codehaus.jackson.JsonParseException - If an error occurred while parsing the data.
IOException - If an error occurred while reading from the stream.

readFields

public void readFields(DuDeJsonParser<?> parser,
                       T instance)
                throws org.codehaus.jackson.JsonParseException,
                       IOException,
                       EOFException
Description copied from class: AutoJsonSerialization
Reads all non-transient fields of the jsonable to the DuDeJsonParser. It expects the given jsonParser to currently have an opened record and it leaves it open.

Overrides:
readFields in class AutoJsonSerialization<T>
Parameters:
parser - the DuDeJsonParser to read from
instance - the AutoJsonable to initialize
Throws:
org.codehaus.jackson.JsonParseException - If an error occurred while parsing the data.
IOException - If an error occurred while reading the data.
EOFException

write

public void write(DuDeJsonGenerator generator,
                  T jsonable)
           throws org.codehaus.jackson.JsonGenerationException,
                  IOException
Writes the given instance to the specified DuDeJsonGenerator.

Specified by:
write in class AutoJsonSerialization<T>
Parameters:
generator - the generator to write to
jsonable - the jsonable to write
Throws:
org.codehaus.jackson.JsonGenerationException - If an error occurs while generating the Json syntax.
IOException - If an error occurs while accessing the underlying stream.

writeFields

public void writeFields(DuDeJsonGenerator generator,
                        Object jsonable)
                 throws org.codehaus.jackson.JsonGenerationException,
                        IOException
Description copied from class: AutoJsonSerialization
Writes all non-transient fields of the jsonable to the DuDeJsonGenerator. It expects the given jsonGenerator to currently have an opened record and it leaves it open.

Overrides:
writeFields in class AutoJsonSerialization<T>
Parameters:
generator - the DuDeJsonGenerator to write to
jsonable - the object, the fields of which to write
Throws:
org.codehaus.jackson.JsonGenerationException - If an error occurs while generating the Json syntax.
IOException - If an error occurs while accessing the underlying stream.


Copyright © 2011 Hasso Plattner Institute - Chair of Information Systems. All Rights Reserved.