org.qi4j.spi.value
Class ValueSerializerAdapter<OutputType>

java.lang.Object
  extended by org.qi4j.spi.value.ValueSerializerAdapter<OutputType>
Type Parameters:
OutputType - Implementor output type
All Implemented Interfaces:
ValueSerializer
Direct Known Subclasses:
OrgJsonValueSerializer

public abstract class ValueSerializerAdapter<OutputType>
extends java.lang.Object
implements ValueSerializer

Adapter for pull-parsing capable ValueSerializers.

Among Plain values (see ValueSerializer) 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
ValueSerializerAdapter()
           
 
Method Summary
protected abstract  OutputType adaptOutput(java.io.OutputStream output)
           
protected abstract  void onArrayEnd(OutputType output)
           
protected abstract  void onArrayStart(OutputType output)
           
protected  void onFieldEnd(OutputType output)
           
protected abstract  void onFieldStart(OutputType output, java.lang.String fieldName)
           
protected abstract  void onObjectEnd(OutputType output)
           
protected abstract  void onObjectStart(OutputType output)
           
protected  void onSerializationEnd(java.lang.Object object, OutputType output)
           
protected  void onSerializationStart(java.lang.Object object, OutputType output)
           
protected abstract  void onValue(OutputType output, java.lang.Object value)
           
protected  void onValueEnd(OutputType output)
           
protected  void onValueStart(OutputType output)
           
protected
<T> void
registerSerializer(java.lang.Class<T> type, Function<T,java.lang.Object> serializer)
          Register a Plain Value type serialization Function.
<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

ValueSerializerAdapter

public ValueSerializerAdapter()
Method Detail

registerSerializer

protected final <T> void registerSerializer(java.lang.Class<T> type,
                                            Function<T,java.lang.Object> serializer)
Register a Plain Value type serialization Function.

Type Parameters:
T - Plain Value parametrized Type
Parameters:
type - Plain Value Type
deserializer - Serialization Function

serialize

public final <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 final <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 final 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 final 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 final 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 final 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

adaptOutput

protected abstract OutputType adaptOutput(java.io.OutputStream output)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

onSerializationStart

protected void onSerializationStart(java.lang.Object object,
                                    OutputType output)
                             throws java.lang.Exception
Throws:
java.lang.Exception

onSerializationEnd

protected void onSerializationEnd(java.lang.Object object,
                                  OutputType output)
                           throws java.lang.Exception
Throws:
java.lang.Exception

onArrayStart

protected abstract void onArrayStart(OutputType output)
                              throws java.lang.Exception
Throws:
java.lang.Exception

onArrayEnd

protected abstract void onArrayEnd(OutputType output)
                            throws java.lang.Exception
Throws:
java.lang.Exception

onObjectStart

protected abstract void onObjectStart(OutputType output)
                               throws java.lang.Exception
Throws:
java.lang.Exception

onObjectEnd

protected abstract void onObjectEnd(OutputType output)
                             throws java.lang.Exception
Throws:
java.lang.Exception

onFieldStart

protected abstract void onFieldStart(OutputType output,
                                     java.lang.String fieldName)
                              throws java.lang.Exception
Throws:
java.lang.Exception

onFieldEnd

protected void onFieldEnd(OutputType output)
                   throws java.lang.Exception
Throws:
java.lang.Exception

onValueStart

protected void onValueStart(OutputType output)
                     throws java.lang.Exception
Throws:
java.lang.Exception

onValue

protected abstract void onValue(OutputType output,
                                java.lang.Object value)
                         throws java.lang.Exception
Throws:
java.lang.Exception

onValueEnd

protected void onValueEnd(OutputType output)
                   throws java.lang.Exception
Throws:
java.lang.Exception