de.hpi.fgis.dude.util.data.json.auto
Class EnumJsonSerialization<E extends Enum<E>>

java.lang.Object
  extended by de.hpi.fgis.dude.util.data.json.auto.AutoJsonSerialization<E>
      extended by de.hpi.fgis.dude.util.data.json.auto.EnumJsonSerialization<E>
Type Parameters:
E - the enum type

 class EnumJsonSerialization<E extends Enum<E>>
extends AutoJsonSerialization<E>

Enum constant serialization.

Author:
Arvid.Heise

Constructor Summary
EnumJsonSerialization(BoundType enumType)
          Initializes the serialization for the given type.
 
Method Summary
 E 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, E jsonable)
          Writes the given instance to the specified DuDeJsonGenerator.
 
Methods inherited from class de.hpi.fgis.dude.util.data.json.auto.AutoJsonSerialization
finishTypeSerializationRead, getRawType, getType, isInstantiable, read, readFields, readSerializedType, writeFields, writeWithType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnumJsonSerialization

public EnumJsonSerialization(BoundType enumType)
Initializes the serialization for the given type.

Parameters:
enumType - the wrapped enum type
Method Detail

write

public void write(DuDeJsonGenerator generator,
                  E jsonable)
           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<E extends Enum<E>>
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.

read

public E 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<E extends Enum<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.


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