de.hpi.fgis.dude.util.data.json.auto
Class CollectionJsonSerialization<E,C extends Collection<E>>

java.lang.Object
  extended by de.hpi.fgis.dude.util.data.json.auto.AutoJsonSerialization<C>
      extended by de.hpi.fgis.dude.util.data.json.auto.CollectionJsonSerialization<E,C>
Type Parameters:
E - the element type
C - the collection type

 class CollectionJsonSerialization<E,C extends Collection<E>>
extends AutoJsonSerialization<C>

Collection json serialization support.

Author:
Arvid.Heise

Constructor Summary
CollectionJsonSerialization(BoundType genericType)
          Initializes the json serialization for the given type.
 
Method Summary
 C 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 write(DuDeJsonGenerator generator, C collection)
          Writes the given instance to the specified DuDeJsonGenerator.
protected  void writeWithType(DuDeJsonGenerator generator, C value)
          Writes the given value with additional type information.
This method should be used when the actual type of a value cannot be inferred from the declaration.
The typical scenario is the usage of polymorphism without secondary information which would allow to infer the type.
 
Methods inherited from class de.hpi.fgis.dude.util.data.json.auto.AutoJsonSerialization
finishTypeSerializationRead, getRawType, getType, isInstantiable, read, readFields, readSerializedType, writeFields
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionJsonSerialization

public CollectionJsonSerialization(BoundType genericType)
Initializes the json serialization for the given type.

Parameters:
genericType - the type to wrap
Method Detail

read

public C read(DuDeJsonParser<?> parser,
              Object currentValue)
                             throws org.codehaus.jackson.JsonParseException,
                                    IOException
Description copied from class: AutoJsonSerialization
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<C extends Collection<E>>
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.

write

public void write(DuDeJsonGenerator generator,
                  C collection)
           throws org.codehaus.jackson.JsonGenerationException,
                  IOException
Description copied from class: AutoJsonSerialization
Writes the given instance to the specified DuDeJsonGenerator.

Specified by:
write in class AutoJsonSerialization<C extends Collection<E>>
Parameters:
generator - the generator to write to
collection - 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.

writeWithType

protected void writeWithType(DuDeJsonGenerator generator,
                             C value)
                      throws org.codehaus.jackson.JsonGenerationException,
                             IOException
Description copied from class: AutoJsonSerialization
Writes the given value with additional type information.
This method should be used when the actual type of a value cannot be inferred from the declaration.
The typical scenario is the usage of polymorphism without secondary information which would allow to infer the type.

Overrides:
writeWithType in class AutoJsonSerialization<C extends Collection<E>>
Parameters:
generator - the DuDeJsonGenerator to write to
value - the object 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.