|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.qi4j.spi.value.ValueDeserializerAdapter<InputType,InputNodeType>
InputType
- Implementor pull-parser typeInputNodeType
- Implementor tree-parser node typepublic abstract class ValueDeserializerAdapter<InputType,InputNodeType>
Adapter for pull-parsing and tree-parsing capable ValueDeserializers.
Among Plain values (see ValueDeserializer
) some are considered primitives to underlying serialization
mechanisms and by so handed/come without conversion to/from implementations. Primitive values can be one of:
Constructor Summary | |
---|---|
protected |
ValueDeserializerAdapter(Application application,
Module module,
Function<Application,Module> valuesModuleFinder)
|
|
ValueDeserializerAdapter(Application application,
Module module,
ServiceReference<ValueDeserializer> serviceRef)
|
Method Summary | ||
---|---|---|
protected abstract InputType |
adaptInput(java.io.InputStream input)
This method is always called first, this is a chance to wrap the input type. |
|
protected abstract java.lang.Object |
asSimpleValue(InputNodeType inputNode)
|
|
|
deserialize()
Factory method for an untyped deserialize function. |
|
|
deserialize(java.lang.Class<?> type,
java.io.InputStream input)
Deserialize a value from a state. |
|
|
deserialize(java.lang.Class<?> type,
java.lang.String input)
Deserialize a value from a state. |
|
|
deserialize(java.lang.Class<T> type)
Factory method for a typed deserialize function. |
|
|
deserialize(ValueType valueType)
Factory method for a typed deserialize function. |
|
|
deserialize(ValueType valueType,
java.io.InputStream input)
Deserialize a value from a state. |
|
|
deserialize(ValueType valueType,
java.lang.String input)
Deserialize a value from a state. |
|
protected abstract
|
getObjectFieldValue(InputNodeType inputNode,
java.lang.String key,
Function<InputNodeType,T> valueDeserializer)
Return null if the field do not exists. |
|
protected abstract boolean |
isObjectValue(InputNodeType inputNode)
|
|
protected abstract boolean |
objectHasField(InputNodeType inputNode,
java.lang.String key)
|
|
protected void |
onDeserializationEnd(ValueType valueType,
InputType input)
Called by the adapter on deserialization end. |
|
protected void |
onDeserializationStart(ValueType valueType,
InputType input)
Called by the adapter on deserialization start, after adaptInput(java.io.InputStream) . |
|
protected abstract
|
putArrayNodeInCollection(InputNodeType inputNode,
Function<InputNodeType,T> deserializer,
java.util.Collection<T> collection)
|
|
protected abstract
|
putArrayNodeInMap(InputNodeType inputNode,
Function<InputNodeType,K> keyDeserializer,
Function<InputNodeType,V> valueDeserializer,
java.util.Map<K,V> map)
|
|
protected abstract
|
readArrayInCollection(InputType input,
Function<InputType,T> deserializer,
java.util.Collection<T> collection)
|
|
protected abstract
|
readMapInMap(InputType input,
Function<InputType,K> keyDeserializer,
Function<InputType,V> valueDeserializer,
java.util.Map<K,V> map)
A Map<K,V> is serialized in an array of entries objects. |
|
protected abstract InputNodeType |
readObjectTree(InputType input)
|
|
protected abstract java.lang.Object |
readPlainValue(InputType input)
|
|
protected
|
registerDeserializer(java.lang.Class<T> type,
Function<java.lang.Object,T> deserializer)
Register a Plain Value type deserialization Function. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ValueDeserializerAdapter(@Structure Application application, @Structure Module module, @Service ServiceReference<ValueDeserializer> serviceRef)
protected ValueDeserializerAdapter(Application application, Module module, Function<Application,Module> valuesModuleFinder)
Method Detail |
---|
protected final <T> void registerDeserializer(java.lang.Class<T> type, Function<java.lang.Object,T> deserializer)
T
- Plain Value parametrized Typetype
- Plain Value Typedeserializer
- Deserialization Functionpublic <T> Function<java.lang.String,T> deserialize(java.lang.Class<T> type)
ValueDeserializer
The returned Function may throw ValueSerializationException
.
deserialize
in interface ValueDeserializer
T
- the parametrized function return typetype
- the value type
public final <T> Function<java.lang.String,T> deserialize(ValueType valueType)
ValueDeserializer
The returned Function may throw ValueSerializationException
.
deserialize
in interface ValueDeserializer
T
- the parametrized function return typevalueType
- the value type
public final <T> Function2<ValueType,java.lang.String,T> deserialize()
ValueDeserializer
The returned Function may throw ValueSerializationException
.
deserialize
in interface ValueDeserializer
T
- the parametrized function return type
public final <T> T deserialize(java.lang.Class<?> type, java.lang.String input) throws ValueSerializationException
ValueDeserializer
deserialize
in interface ValueDeserializer
T
- the parametrized returned typetype
- the value typeinput
- the state
ValueSerializationException
- if the deserialization failedpublic final <T> T deserialize(ValueType valueType, java.lang.String input) throws ValueSerializationException
ValueDeserializer
deserialize
in interface ValueDeserializer
T
- the parametrized returned typevalueType
- the value typeinput
- the state
ValueSerializationException
- if the deserialization failedpublic final <T> T deserialize(java.lang.Class<?> type, java.io.InputStream input) throws ValueSerializationException
ValueDeserializer
deserialize
in interface ValueDeserializer
T
- the parametrized returned typetype
- the value typeinput
- the state stream
ValueSerializationException
- if the deserialization failedpublic final <T> T deserialize(ValueType valueType, java.io.InputStream input) throws ValueSerializationException
ValueDeserializer
deserialize
in interface ValueDeserializer
T
- the parametrized returned typevalueType
- the value typeinput
- the state stream
ValueSerializationException
- if the deserialization failedprotected void onDeserializationStart(ValueType valueType, InputType input) throws java.lang.Exception
adaptInput(java.io.InputStream)
.
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected void onDeserializationEnd(ValueType valueType, InputType input) throws java.lang.Exception
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected abstract InputType adaptInput(java.io.InputStream input) throws java.lang.Exception
input
- InputStream to adapt
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected abstract java.lang.Object readPlainValue(InputType input) throws java.lang.Exception
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected abstract <T> java.util.Collection<T> readArrayInCollection(InputType input, Function<InputType,T> deserializer, java.util.Collection<T> collection) throws java.lang.Exception
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected abstract <K,V> java.util.Map<K,V> readMapInMap(InputType input, Function<InputType,K> keyDeserializer, Function<InputType,V> valueDeserializer, java.util.Map<K,V> map) throws java.lang.Exception
Here is an example in JSON:
[ { "key": "foo", "value": "bar" }, { "key": "cathedral", "value": "bazar" } ]
And an empty Map:
[]
This allow to use any type as keys and values while keeping the Map order at the cost of having non-predictible order of key/value inside an entry object.
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected abstract InputNodeType readObjectTree(InputType input) throws java.lang.Exception
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected abstract java.lang.Object asSimpleValue(InputNodeType inputNode) throws java.lang.Exception
java.lang.Exception
protected abstract boolean isObjectValue(InputNodeType inputNode) throws java.lang.Exception
java.lang.Exception
protected abstract boolean objectHasField(InputNodeType inputNode, java.lang.String key) throws java.lang.Exception
java.lang.Exception
protected abstract <T> T getObjectFieldValue(InputNodeType inputNode, java.lang.String key, Function<InputNodeType,T> valueDeserializer) throws java.lang.Exception
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected abstract <T> void putArrayNodeInCollection(InputNodeType inputNode, Function<InputNodeType,T> deserializer, java.util.Collection<T> collection) throws java.lang.Exception
java.lang.Exception
protected abstract <K,V> void putArrayNodeInMap(InputNodeType inputNode, Function<InputNodeType,K> keyDeserializer, Function<InputNodeType,V> valueDeserializer, java.util.Map<K,V> map) throws java.lang.Exception
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |