public class StaxValueDeserializer extends ValueDeserializerAdapter<XMLEventReader,Node>
ValueDeserializerAdapter.ComplexDeserializer<T,InputType,InputNodeType>| Constructor and Description |
|---|
StaxValueDeserializer(Application application,
Module module,
ServiceReference<ValueDeserializer> serviceRef) |
| Modifier and Type | Method and Description |
|---|---|
protected XMLEventReader |
adaptInput(InputStream input)
This method is always called first, this is a chance to wrap the input type.
|
protected Object |
asSimpleValue(Node inputNode) |
protected <T> T |
getObjectFieldValue(Node inputNode,
String key,
Function<Node,T> valueDeserializer)
Return null if the field do not exists.
|
protected boolean |
isObjectValue(Node inputNode) |
protected boolean |
objectHasField(Node inputNode,
String key) |
protected <T> void |
putArrayNodeInCollection(Node inputNode,
Function<Node,T> deserializer,
Collection<T> collection) |
protected <K,V> void |
putArrayNodeInMap(Node inputNode,
Function<Node,K> keyDeserializer,
Function<Node,V> valueDeserializer,
Map<K,V> map) |
protected <V> void |
putObjectNodeInMap(Node inputNode,
Function<Node,V> valueDeserializer,
Map<String,V> map) |
protected <T> Collection<T> |
readArrayInCollection(XMLEventReader input,
Function<XMLEventReader,T> deserializer,
Collection<T> collection) |
protected <K,V> Map<K,V> |
readMapInMap(XMLEventReader input,
Function<XMLEventReader,K> keyDeserializer,
Function<XMLEventReader,V> valueDeserializer,
Map<K,V> map)
A Map<K,V> is serialized in an array of entries objects.
|
protected Node |
readObjectTree(XMLEventReader input) |
protected Object |
readPlainValue(XMLEventReader input) |
deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, onDeserializationEnd, onDeserializationStart, registerComplexDeserializer, registerDeserializerpublic StaxValueDeserializer(@Structure Application application, @Structure Module module, @Service ServiceReference<ValueDeserializer> serviceRef)
protected XMLEventReader adaptInput(InputStream input) throws Exception
ValueDeserializerAdapteradaptInput in class ValueDeserializerAdapter<XMLEventReader,Node>input - InputStream to adaptException - that will be wrapped in a ValueSerializationExceptionprotected Object readPlainValue(XMLEventReader input) throws Exception
readPlainValue in class ValueDeserializerAdapter<XMLEventReader,Node>input - InputException - that will be wrapped in a ValueSerializationExceptionprotected <T> Collection<T> readArrayInCollection(XMLEventReader input, Function<XMLEventReader,T> deserializer, Collection<T> collection) throws Exception
readArrayInCollection in class ValueDeserializerAdapter<XMLEventReader,Node>T - Parameterized collection typeinput - Inputdeserializer - Deserialization functioncollection - CollectionException - that will be wrapped in a ValueSerializationExceptionprotected <K,V> Map<K,V> readMapInMap(XMLEventReader input, Function<XMLEventReader,K> keyDeserializer, Function<XMLEventReader,V> valueDeserializer, Map<K,V> map) throws Exception
ValueDeserializerAdapterHere 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.
readMapInMap in class ValueDeserializerAdapter<XMLEventReader,Node>K - Parameterized map key typeV - Parameterized map value typeinput - InputkeyDeserializer - Map key deserialization functionvalueDeserializer - Map value deserialization functionmap - MapException - that will be wrapped in a ValueSerializationExceptionprotected Node readObjectTree(XMLEventReader input) throws Exception
readObjectTree in class ValueDeserializerAdapter<XMLEventReader,Node>input - InputException - that will be wrapped in a ValueSerializationExceptionprotected Object asSimpleValue(Node inputNode) throws Exception
asSimpleValue in class ValueDeserializerAdapter<XMLEventReader,Node>Exceptionprotected boolean isObjectValue(Node inputNode) throws Exception
isObjectValue in class ValueDeserializerAdapter<XMLEventReader,Node>Exceptionprotected boolean objectHasField(Node inputNode, String key) throws Exception
objectHasField in class ValueDeserializerAdapter<XMLEventReader,Node>Exceptionprotected <T> T getObjectFieldValue(Node inputNode, String key, Function<Node,T> valueDeserializer) throws Exception
ValueDeserializerAdaptergetObjectFieldValue in class ValueDeserializerAdapter<XMLEventReader,Node>T - Parameterized object field value typeinputNode - Input Nodekey - Object keyvalueDeserializer - Deserialization functionException - that will be wrapped in a ValueSerializationExceptionprotected <T> void putArrayNodeInCollection(Node inputNode, Function<Node,T> deserializer, Collection<T> collection) throws Exception
putArrayNodeInCollection in class ValueDeserializerAdapter<XMLEventReader,Node>Exceptionprotected <K,V> void putArrayNodeInMap(Node inputNode, Function<Node,K> keyDeserializer, Function<Node,V> valueDeserializer, Map<K,V> map) throws Exception
putArrayNodeInMap in class ValueDeserializerAdapter<XMLEventReader,Node>Exceptionprotected <V> void putObjectNodeInMap(Node inputNode, Function<Node,V> valueDeserializer, Map<String,V> map) throws Exception
putObjectNodeInMap in class ValueDeserializerAdapter<XMLEventReader,Node>Exception