|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.hpi.fgis.dude.util.data.json.auto.AutoJsonSerialization<T>
T
- the type to serializepublic abstract class AutoJsonSerialization<T>
Provides json serialization for a specific BoundType
.
Constructor Summary | |
---|---|
protected |
AutoJsonSerialization(BoundType type)
Initialization for the given type |
Method Summary | |
---|---|
protected void |
finishTypeSerializationRead(DuDeJsonParser<?> parser,
Class<T> serializedType)
Cleanup method used in conjunction with #readSerializedType(DuDeJsonParser, boolean) . |
Class<T> |
getRawType()
Returns the raw type for which this serialization class was created. |
BoundType |
getType()
Returns the BoundType for which this serialization class was created. |
protected boolean |
isInstantiable(Class<? extends Object> clazz)
Determines whether the given class has an accessible default constructor and caches the result. |
T |
read(DuDeJsonParser<?> parser)
Creates an instance of the wrapped type and initializes the content with the json provided by the given DuDeJsonParser . |
abstract 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 jsonable)
Reads all non-transient fields of the jsonable to the DuDeJsonParser . |
protected Class<T> |
readSerializedType(DuDeJsonParser<?> parser,
boolean leaveRecordIntact,
Class<?> declaredType)
Parsing equivalent of writeWithType(DuDeJsonGenerator, Object) .Since the type is not written in every case, this method also supports a non-destructive way for testing of type information. If leaveRecordIntact is set and no type information has been detected, it appears as if the method has never been invoked. However, if type information has been detected, it shall be removed from the stream and the parsed class shall be returned. |
abstract 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 . |
protected void |
writeWithType(DuDeJsonGenerator generator,
T jsonable)
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AutoJsonSerialization(BoundType type)
type
- the wrapped typeMethod Detail |
---|
public Class<T> getRawType()
public BoundType getType()
BoundType
for which this serialization class was created.
BoundType
protected boolean isInstantiable(Class<? extends Object> clazz)
clazz
- the class to check
ReflectUtil.newInstance(Class)
public final T read(DuDeJsonParser<?> parser) throws org.codehaus.jackson.JsonParseException, IOException
DuDeJsonParser
.
parser
- the parser to read from
T
org.codehaus.jackson.JsonParseException
- If an error occurred while parsing the data.
IOException
- If an error occurred while reading from the stream.public abstract T read(DuDeJsonParser<?> parser, Object currentValue) throws org.codehaus.jackson.JsonParseException, IOException
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.
parser
- the parser to read fromcurrentValue
- the current value of the field which should be populated by the result of this method or null if this is the root object
T
org.codehaus.jackson.JsonParseException
- If an error occurred while parsing the data.
IOException
- If an error occurred while reading from the stream.public void readFields(DuDeJsonParser<?> parser, T jsonable) throws org.codehaus.jackson.JsonParseException, IOException
DuDeJsonParser
. It expects the given jsonParser to currently have an opened
record and it leaves it open.
parser
- the DuDeJsonParser
to read fromjsonable
- the AutoJsonable
to initialize
org.codehaus.jackson.JsonParseException
- If an error occurred while parsing the data.
IOException
- If an error occurred while reading the data.public abstract void write(DuDeJsonGenerator generator, T jsonable) throws org.codehaus.jackson.JsonGenerationException, IOException
DuDeJsonGenerator
.
generator
- the generator to write tojsonable
- the jsonable to write
org.codehaus.jackson.JsonGenerationException
- If an error occurs while generating the Json syntax.
IOException
- If an error occurs while accessing the underlying stream.public void writeFields(DuDeJsonGenerator generator, Object jsonable) throws org.codehaus.jackson.JsonGenerationException, IOException
DuDeJsonGenerator
. It expects the given jsonGenerator to currently have an
opened record and it leaves it open.
generator
- the DuDeJsonGenerator
to write tojsonable
- the object, the fields of which to write
org.codehaus.jackson.JsonGenerationException
- If an error occurs while generating the Json syntax.
IOException
- If an error occurs while accessing the underlying stream.protected void writeWithType(DuDeJsonGenerator generator, T jsonable) throws org.codehaus.jackson.JsonGenerationException, IOException
generator
- the DuDeJsonGenerator
to write tojsonable
- the object to write
org.codehaus.jackson.JsonGenerationException
- If an error occurs while generating the Json syntax.
IOException
- If an error occurs while accessing the underlying stream.protected Class<T> readSerializedType(DuDeJsonParser<?> parser, boolean leaveRecordIntact, Class<?> declaredType) throws org.codehaus.jackson.JsonParseException, IOException
writeWithType(DuDeJsonGenerator, Object)
.
parser
- the DuDeJsonParser
to read fromleaveRecordIntact
- true if the record should not be opened if no type information is encoded in the jsondeclaredType
- the declared type of the field
org.codehaus.jackson.JsonParseException
- If the class cannot be resolved or an error occurred while parsing the data.
IOException
- If an error occurred while reading the data.protected void finishTypeSerializationRead(DuDeJsonParser<?> parser, Class<T> serializedType) throws org.codehaus.jackson.JsonParseException, IOException
#readSerializedType(DuDeJsonParser, boolean)
.
parser
- the DuDeJsonParser
to read fromserializedType
- the return value of #readSerializedType(DuDeJsonParser, boolean)
org.codehaus.jackson.JsonParseException
- If the class cannot be resolved or an error occurred while parsing the data.
IOException
- If an error occurred while reading the data.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |