org.qi4j.spi.value

## Class ValueSerializerAdapter<OutputType>

- java.lang.Object
- - org.qi4j.spi.value.ValueSerializerAdapter<OutputType>

- Type Parameters:
    `OutputType` - Implementor output type
  All Implemented Interfaces:
    ValueSerializer
  Direct Known Subclasses:
    JacksonValueSerializer, OrgJsonValueSerializer, StaxValueSerializer

      public abstract class ValueSerializerAdapter<OutputType>
      extends 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:

  - String,
  - Character or char,
  - Boolean or boolean,
  - Integer or int,
  - Long or long,
  - Short or short,
  - Byte or byte,
  - Float or float,
  - Double or double.

  Some other Plain values are transformed before being handed to implementations:

  - BigInteger and BigDecimal depends on ValueSerializer.`ValueSerializer.Options`;
  - Date as a ISO-8601 UTC String;
  - DateTime (JodaTime) as a ISO-8601 String with timezone offset or Z for UTC;
  - LocalDateTime (JodaTime) as a ISO-8601 String with no timezone offset;
  - LocalDate (JodaTime) as a ISO-8601 String with no time info;

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `ValueSerializerAdapter.ComplexSerializer<T,OutputType>`

    - ### Nested classes/interfaces inherited from interface org.qi4j.api.value.ValueSerializer

      `ValueSerializer.Options`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ValueSerializerAdapter()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract OutputType` | `adaptOutput(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, String fieldName)`
    `protected abstract void` | `onObjectEnd(OutputType output)`
    `protected abstract void` | `onObjectStart(OutputType output)`
    `protected void` | `onSerializationEnd(Object object, OutputType output)`
    `protected void` | `onSerializationStart(Object object, OutputType output)`
    `protected abstract void` | `onValue(OutputType output, Object value)`
    `protected void` | `onValueEnd(OutputType output)`
    `protected void` | `onValueStart(OutputType output)`
    `protected <T> void` | `registerComplexSerializer(Class<T> type, ValueSerializerAdapter.ComplexSerializer<T,OutputType> serializer)` Register a Complex Value type serialization Function.
    `protected <T> void` | `registerSerializer(Class<T> type, Function2<ValueSerializer.Options,T,Object> serializer)` Register a Plain Value type serialization Function.
    `<T> Function<T,String>` | `serialize()` Factory method for a serialize function.
    `<T> Function<T,String>` | `serialize(boolean includeTypeInfo)` Deprecated.
    `String` | `serialize(Object object)` Serialize the state of a value with type information.
    `String` | `serialize(Object object, boolean includeTypeInfo)` Deprecated.
    `void` | `serialize(Object object, OutputStream output)` Serialize the state of a value with type information.
    `void` | `serialize(Object object, OutputStream output, boolean includeTypeInfo)` Deprecated.
    `<T> Function<T,String>` | `serialize(ValueSerializer.Options options)` Factory method for a serialize function.
    `String` | `serialize(ValueSerializer.Options options, Object object)` Serialize the state of a value.
    `void` | `serialize(ValueSerializer.Options options, Object object, OutputStream output)` 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(Class<T> type,
                                    Function2<ValueSerializer.Options,T,Object> serializer)

      Register a Plain Value type serialization Function.
      Type Parameters:
        `T` - Plain Value parametrized Type
      Parameters:
        `type` - Plain Value Type
        `serializer` - Serialization Function

    - #### registerComplexSerializer

          protected final <T> void registerComplexSerializer(Class<T> type,
                                           ValueSerializerAdapter.ComplexSerializer<T,OutputType> serializer)

      Register a Complex Value type serialization Function.
      Type Parameters:
        `T` - Complex Value parametrized Type
      Parameters:
        `type` - Complex Value Type
        `serializer` - Serialization Function

    - #### serialize

          public final <T> Function<T,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,String> serialize(ValueSerializer.Options options)

      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:
        `options` - ValueSerializer Options
      Returns:
        a serialization function.

    - #### serialize

          @Deprecated
          public final <T> Function<T,String> serialize(boolean includeTypeInfo)

      Deprecated.
      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 String serialize(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 String serialize(ValueSerializer.Options options,
                         Object object)
                                 throws ValueSerializationException

      Description copied from interface: `ValueSerializer`
      Serialize the state of a value.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Parameters:
        `options` - ValueSerializer Options
        `object` - an Object to serialize
      Returns:
        the state
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          @Deprecated
          public final String serialize(Object object,
                                    boolean includeTypeInfo)
                                 throws ValueSerializationException

      Deprecated.
      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(Object object,
                       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(ValueSerializer.Options options,
                       Object object,
                       OutputStream output)
                               throws ValueSerializationException

      Description copied from interface: `ValueSerializer`
      Serialize the state of a value.
      Specified by:
        `serialize` in interface `ValueSerializer`
      Parameters:
        `options` - ValueSerializer Options
        `object` - an Object to serialize
        `output` - that will be used as output
      Throws:
        `ValueSerializationException` - if the Value serialization failed

    - #### serialize

          @Deprecated
          public final void serialize(Object object,
                                  OutputStream output,
                                  boolean includeTypeInfo)
                               throws ValueSerializationException

      Deprecated.
      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(OutputStream output)
                                             throws Exception

      Throws:
        `Exception`

    - #### onSerializationStart

          protected void onSerializationStart(Object object,
                                  OutputType output)
                                       throws Exception

      Throws:
        `Exception`

    - #### onSerializationEnd

          protected void onSerializationEnd(Object object,
                                OutputType output)
                                     throws Exception

      Throws:
        `Exception`

    - #### onArrayStart

          protected abstract void onArrayStart(OutputType output)
                                        throws Exception

      Throws:
        `Exception`

    - #### onArrayEnd

          protected abstract void onArrayEnd(OutputType output)
                                      throws Exception

      Throws:
        `Exception`

    - #### onObjectStart

          protected abstract void onObjectStart(OutputType output)
                                         throws Exception

      Throws:
        `Exception`

    - #### onObjectEnd

          protected abstract void onObjectEnd(OutputType output)
                                       throws Exception

      Throws:
        `Exception`

    - #### onFieldStart

          protected abstract void onFieldStart(OutputType output,
                          String fieldName)
                                        throws Exception

      Throws:
        `Exception`

    - #### onFieldEnd

          protected void onFieldEnd(OutputType output)
                             throws Exception

      Throws:
        `Exception`

    - #### onValueStart

          protected void onValueStart(OutputType output)
                               throws Exception

      Throws:
        `Exception`

    - #### onValue

          protected abstract void onValue(OutputType output,
                     Object value)
                                   throws Exception

      Throws:
        `Exception`

    - #### onValueEnd

          protected void onValueEnd(OutputType output)
                             throws Exception

      Throws:
        `Exception`