Package org.apache.batchee.container.services.data

## Class DefaultDataRepresentationService

- java.lang.Object
- - org.apache.batchee.container.services.data.DefaultDataRepresentationService

- All Implemented Interfaces:
    `BatchService`, `DataRepresentationService`

      public class DefaultDataRepresentationService
      extends Object
      implements DataRepresentationService

  Default implementation of the `DataRepresentationService`

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `BATCHEE_DATA_PREFIX` |
    `static String` | `BATCHEE_SPLIT_TOKEN` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultDataRepresentationService()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected <T> T` | `convertBackJava7DateTypes​(String typeVal, String valueVal)` |
    `protected <T> T` | `convertBackJavaNativeTypes​(String typeVal, String value)` |
    `protected <T> T` | `convertBackSerializableObjectTypes​(byte[] internalRepresentation)` |
    `protected <T> byte[]` | `convertCustomTypes​(T dataObject)` | This is an extension point for other serialisation algorithms.
    `protected <T> byte[]` | `convertJava7DateTypes​(T dataObject)` | Convert javas internal Date objects to db representation.
    `protected <T> byte[]` | `convertJavaNativeTypes​(T dataObject)` | This method converts java native types to a 'nice' string representation which will be stored in the database.
    `protected <T> byte[]` | `convertSerializableObjectTypes​(T dataObject)` | This is the default operation if no other way to serialise the data was used
    `protected ClassLoader` | `getClassLoader()` |
    `protected SimpleDateFormat` | `getSimpleDateFormat()` |
    `protected SimpleDateFormat` | `getTimestampDateFormat()` | Attention: The nanos must get concatenated separately as there is no formatter for nanos!
    `void` | `init​(Properties batchConfig)` |
    `protected Object` | `invokeStaticMethod​(String typeVal, String methodName, Class paramType, String valueVal)` |
    `protected byte[]` | `toBatchEeData​(Class<?> type, String stringRepresentation)` |
    `<T> byte[]` | `toInternalRepresentation​(T dataObject)` | Convert the given dataObject into something which can be stored in a BLOB in the database.
    `<T> T` | `toJavaRepresentation​(byte[] internalRepresentation)` | Convert the internal representation stored in the `PersistenceManagerService` to the Java objects needed by the batch artifacts.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BATCHEE_SPLIT_TOKEN

          public static final String BATCHEE_SPLIT_TOKEN

      See Also:
        Constant Field Values

    - #### BATCHEE_DATA_PREFIX

          public static final String BATCHEE_DATA_PREFIX

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DefaultDataRepresentationService

          public DefaultDataRepresentationService()

  - ### Method Detail

    - #### init

          public void init​(Properties batchConfig)

      Specified by:
        `init` in interface `BatchService`

    - #### toInternalRepresentation

          public <T> byte[] toInternalRepresentation​(T dataObject)

      Description copied from interface: `DataRepresentationService`
      Convert the given dataObject into something which can be stored in a BLOB in the database.
      Specified by:
        `toInternalRepresentation` in interface `DataRepresentationService`
      Parameters:
        `dataObject` - the object to store or `null` if no data is to be stored
      Returns:
        the internal representation of the dataObject

    - #### toJavaRepresentation

          public <T> T toJavaRepresentation​(byte[] internalRepresentation)

      Description copied from interface: `DataRepresentationService`
      Convert the internal representation stored in the `PersistenceManagerService` to the Java objects needed by the batch artifacts.
      Specified by:
        `toJavaRepresentation` in interface `DataRepresentationService`
      Parameters:
        `internalRepresentation` - the String representation which we store in the databas
      Returns:
        the dataObject

    - #### convertCustomTypes

          protected <T> byte[] convertCustomTypes​(T dataObject)

      This is an extension point for other serialisation algorithms.

    - #### convertJavaNativeTypes

          protected <T> byte[] convertJavaNativeTypes​(T dataObject)

      This method converts java native types to a 'nice' string representation which will be stored in the database.
      Returns:
        the String representation or `null` if the dataObject was not a native Java type

    - #### convertBackJavaNativeTypes

          protected <T> T convertBackJavaNativeTypes​(String typeVal,
                                                     String value)

    - #### convertJava7DateTypes

          protected <T> byte[] convertJava7DateTypes​(T dataObject)

      Convert javas internal Date objects to db representation. The converted types are:
      - java.util.Date
      - java.sql.Date
      - java.sql.Timestamp

    - #### convertBackJava7DateTypes

          protected <T> T convertBackJava7DateTypes​(String typeVal,
                                                    String valueVal)

    - #### invokeStaticMethod

          protected Object invokeStaticMethod​(String typeVal,
                                              String methodName,
                                              Class paramType,
                                              String valueVal)

    - #### convertSerializableObjectTypes

          protected <T> byte[] convertSerializableObjectTypes​(T dataObject)

      This is the default operation if no other way to serialise the data was used

    - #### convertBackSerializableObjectTypes

          protected <T> T convertBackSerializableObjectTypes​(byte[] internalRepresentation)

    - #### toBatchEeData

          protected byte[] toBatchEeData​(Class<?> type,
                                         String stringRepresentation)

    - #### getClassLoader

          protected ClassLoader getClassLoader()

    - #### getSimpleDateFormat

          protected SimpleDateFormat getSimpleDateFormat()

    - #### getTimestampDateFormat

          protected SimpleDateFormat getTimestampDateFormat()

      Attention: The nanos must get concatenated separately as there is no formatter for nanos!