org.qi4j.valueserialization.orgjson
Class OrgJsonValueSerialization

java.lang.Object
  extended by org.qi4j.valueserialization.orgjson.OrgJsonValueSerialization
All Implemented Interfaces:
ValueDeserializer, ValueSerialization, ValueSerializer

public class OrgJsonValueSerialization
extends java.lang.Object
implements ValueSerialization

ValueSerialization producing and consuming JSON documents using org.json.

This class is used internally by the Qi4j Runtime to provide default ValueSerialization when no ValueSerialization Service is available.

In application code, prefer the use of OrgJsonValueSerializationService.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.qi4j.api.value.ValueSerialization
ValueSerialization.Formats
 
Constructor Summary
OrgJsonValueSerialization(Application application, Module module, Module valuesModule)
           
 
Method Summary
<T> Function2<ValueType,java.lang.String,T>
deserialize()
          Factory method for an untyped deserialize function.
<T> T
deserialize(java.lang.Class<?> type, java.io.InputStream input)
          Deserialize a value from a state.
<T> T
deserialize(java.lang.Class<?> type, java.lang.String input)
          Deserialize a value from a state.
<T> Function<java.lang.String,T>
deserialize(java.lang.Class<T> type)
          Factory method for a typed deserialize function.
<T> Function<java.lang.String,T>
deserialize(ValueType valueType)
          Factory method for a typed deserialize function.
<T> T
deserialize(ValueType type, java.io.InputStream input)
          Deserialize a value from a state.
<T> T
deserialize(ValueType type, java.lang.String input)
          Deserialize a value from a state.
<T> Function<T,java.lang.String>
serialize()
          Factory method for a serialize function.
<T> Function<T,java.lang.String>
serialize(boolean includeTypeInfo)
          Factory method for a serialize function.
 java.lang.String serialize(java.lang.Object object)
          Serialize the state of a value with type information.
 java.lang.String serialize(java.lang.Object object, boolean includeTypeInfo)
          Serialize the state of a value.
 void serialize(java.lang.Object object, java.io.OutputStream output)
          Serialize the state of a value with type information.
 void serialize(java.lang.Object object, java.io.OutputStream output, boolean includeTypeInfo)
          Serialize the state of a value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrgJsonValueSerialization

public OrgJsonValueSerialization(Application application,
                                 Module module,
                                 Module valuesModule)
Method Detail

serialize

public <T> Function<T,java.lang.String> serialize()
Description copied from interface: ValueSerializer
Factory method for a serialize function.

Specified by:
serialize in interface ValueSerializer
Type Parameters:
T - the parametrized function input type
Returns:
a serialization function.

serialize

public <T> Function<T,java.lang.String> serialize(boolean includeTypeInfo)
Description copied from interface: ValueSerializer
Factory method for a serialize function.

Specified by:
serialize in interface ValueSerializer
Type Parameters:
T - the parametrized function input type
Parameters:
includeTypeInfo - if type information should be included in the output
Returns:
a serialization function.

serialize

public java.lang.String serialize(java.lang.Object object)
                           throws ValueSerializationException
Description copied from interface: ValueSerializer
Serialize the state of a value with type information.

Specified by:
serialize in interface ValueSerializer
Parameters:
object - an Object to serialize
Returns:
the state
Throws:
ValueSerializationException - if the Value serialization failed

serialize

public java.lang.String serialize(java.lang.Object object,
                                  boolean includeTypeInfo)
                           throws ValueSerializationException
Description copied from interface: ValueSerializer
Serialize the state of a value.

Specified by:
serialize in interface ValueSerializer
Parameters:
object - an Object to serialize
includeTypeInfo - if type information should be included in the output
Returns:
the state
Throws:
ValueSerializationException - if the Value serialization failed

serialize

public void serialize(java.lang.Object object,
                      java.io.OutputStream output)
               throws ValueSerializationException
Description copied from interface: ValueSerializer
Serialize the state of a value with type information.

Specified by:
serialize in interface ValueSerializer
Parameters:
object - an Object to serialize
output - that will be used as output
Throws:
ValueSerializationException - if the Value serialization failed

serialize

public void serialize(java.lang.Object object,
                      java.io.OutputStream output,
                      boolean includeTypeInfo)
               throws ValueSerializationException
Description copied from interface: ValueSerializer
Serialize the state of a value.

Specified by:
serialize in interface ValueSerializer
Parameters:
object - an Object to serialize
output - that will be used as output
includeTypeInfo - if type information should be included in the output
Throws:
ValueSerializationException - if the Value serialization failed

deserialize

public <T> Function<java.lang.String,T> deserialize(java.lang.Class<T> type)
Description copied from interface: ValueDeserializer
Factory method for a typed deserialize function.

The returned Function may throw ValueSerializationException.

Specified by:
deserialize in interface ValueDeserializer
Type Parameters:
T - the parametrized function return type
Parameters:
type - the value type
Returns:
a deserialization function

deserialize

public <T> Function<java.lang.String,T> deserialize(ValueType valueType)
Description copied from interface: ValueDeserializer
Factory method for a typed deserialize function.

The returned Function may throw ValueSerializationException.

Specified by:
deserialize in interface ValueDeserializer
Type Parameters:
T - the parametrized function return type
Parameters:
valueType - the value type
Returns:
a deserialization function

deserialize

public <T> Function2<ValueType,java.lang.String,T> deserialize()
Description copied from interface: ValueDeserializer
Factory method for an untyped deserialize function.

The returned Function may throw ValueSerializationException.

Specified by:
deserialize in interface ValueDeserializer
Type Parameters:
T - the parametrized function return type
Returns:
a deserialization function

deserialize

public <T> T deserialize(java.lang.Class<?> type,
                         java.lang.String input)
              throws ValueSerializationException
Description copied from interface: ValueDeserializer
Deserialize a value from a state.

Specified by:
deserialize in interface ValueDeserializer
Type Parameters:
T - the parametrized returned type
Parameters:
type - the value type
input - the state
Returns:
the value
Throws:
ValueSerializationException - if the deserialization failed

deserialize

public <T> T deserialize(ValueType type,
                         java.lang.String input)
              throws ValueSerializationException
Description copied from interface: ValueDeserializer
Deserialize a value from a state.

Specified by:
deserialize in interface ValueDeserializer
Type Parameters:
T - the parametrized returned type
Parameters:
type - the value type
input - the state
Returns:
the value
Throws:
ValueSerializationException - if the deserialization failed

deserialize

public <T> T deserialize(java.lang.Class<?> type,
                         java.io.InputStream input)
              throws ValueSerializationException
Description copied from interface: ValueDeserializer
Deserialize a value from a state.

Specified by:
deserialize in interface ValueDeserializer
Type Parameters:
T - the parametrized returned type
Parameters:
type - the value type
input - the state stream
Returns:
the value
Throws:
ValueSerializationException - if the deserialization failed

deserialize

public <T> T deserialize(ValueType type,
                         java.io.InputStream input)
              throws ValueSerializationException
Description copied from interface: ValueDeserializer
Deserialize a value from a state.

Specified by:
deserialize in interface ValueDeserializer
Type Parameters:
T - the parametrized returned type
Parameters:
type - the value type
input - the state stream
Returns:
the value
Throws:
ValueSerializationException - if the deserialization failed