|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.qi4j.spi.value.ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
org.qi4j.valueserialization.orgjson.OrgJsonValueDeserializer
public class OrgJsonValueDeserializer
ValueDeserializer reading Values from JSON documents using org.json.
Constructor Summary | |
---|---|
OrgJsonValueDeserializer(Application application,
Module module,
ServiceReference<ValueDeserializer> serviceRef)
|
Method Summary | ||
---|---|---|
protected org.json.JSONTokener |
adaptInput(java.io.InputStream input)
This method is always called first, this is a chance to wrap the input type. |
|
protected java.lang.Object |
asSimpleValue(java.lang.Object inputNode)
|
|
protected
|
getObjectFieldValue(java.lang.Object inputNode,
java.lang.String key,
Function<java.lang.Object,T> valueDeserializer)
Return null if the field do not exists. |
|
protected boolean |
isObjectValue(java.lang.Object inputNode)
|
|
protected boolean |
objectHasField(java.lang.Object inputNode,
java.lang.String key)
|
|
protected
|
putArrayNodeInCollection(java.lang.Object inputNode,
Function<java.lang.Object,T> deserializer,
java.util.Collection<T> collection)
|
|
protected
|
putArrayNodeInMap(java.lang.Object inputNode,
Function<java.lang.Object,K> keyDeserializer,
Function<java.lang.Object,V> valueDeserializer,
java.util.Map<K,V> map)
|
|
protected
|
readArrayInCollection(org.json.JSONTokener input,
Function<org.json.JSONTokener,T> deserializer,
java.util.Collection<T> collection)
|
|
protected
|
readMapInMap(org.json.JSONTokener input,
Function<org.json.JSONTokener,K> keyDeserializer,
Function<org.json.JSONTokener,V> valueDeserializer,
java.util.Map<K,V> map)
A Map<K,V> is serialized in an array of entries objects. |
|
protected org.json.JSONObject |
readObjectTree(org.json.JSONTokener input)
|
|
protected java.lang.Object |
readPlainValue(org.json.JSONTokener input)
|
Methods inherited from class org.qi4j.spi.value.ValueDeserializerAdapter |
---|
deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, deserialize, onDeserializationEnd, onDeserializationStart, registerDeserializer |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OrgJsonValueDeserializer(@Structure Application application, @Structure Module module, @Service ServiceReference<ValueDeserializer> serviceRef)
Method Detail |
---|
protected org.json.JSONTokener adaptInput(java.io.InputStream input) throws java.lang.Exception
ValueDeserializerAdapter
adaptInput
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
input
- InputStream to adapt
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected java.lang.Object readPlainValue(org.json.JSONTokener input) throws java.lang.Exception
readPlainValue
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected <T> java.util.Collection<T> readArrayInCollection(org.json.JSONTokener input, Function<org.json.JSONTokener,T> deserializer, java.util.Collection<T> collection) throws java.lang.Exception
readArrayInCollection
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected <K,V> java.util.Map<K,V> readMapInMap(org.json.JSONTokener input, Function<org.json.JSONTokener,K> keyDeserializer, Function<org.json.JSONTokener,V> valueDeserializer, java.util.Map<K,V> map) throws java.lang.Exception
ValueDeserializerAdapter
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.
readMapInMap
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected org.json.JSONObject readObjectTree(org.json.JSONTokener input) throws java.lang.Exception
readObjectTree
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected java.lang.Object asSimpleValue(java.lang.Object inputNode) throws java.lang.Exception
asSimpleValue
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
protected boolean isObjectValue(java.lang.Object inputNode) throws java.lang.Exception
isObjectValue
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
protected boolean objectHasField(java.lang.Object inputNode, java.lang.String key) throws java.lang.Exception
objectHasField
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
protected <T> T getObjectFieldValue(java.lang.Object inputNode, java.lang.String key, Function<java.lang.Object,T> valueDeserializer) throws java.lang.Exception
ValueDeserializerAdapter
getObjectFieldValue
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
- that will be wrapped in a ValueSerializationException
protected <T> void putArrayNodeInCollection(java.lang.Object inputNode, Function<java.lang.Object,T> deserializer, java.util.Collection<T> collection) throws java.lang.Exception
putArrayNodeInCollection
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
protected <K,V> void putArrayNodeInMap(java.lang.Object inputNode, Function<java.lang.Object,K> keyDeserializer, Function<java.lang.Object,V> valueDeserializer, java.util.Map<K,V> map) throws java.lang.Exception
putArrayNodeInMap
in class ValueDeserializerAdapter<org.json.JSONTokener,java.lang.Object>
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |