org.camunda.bpm.engine.impl.variable.serializer
Class AbstractObjectValueSerializer

java.lang.Object
  extended by org.camunda.bpm.engine.impl.variable.serializer.AbstractTypedValueSerializer<ObjectValue>
      extended by org.camunda.bpm.engine.impl.variable.serializer.AbstractObjectValueSerializer
All Implemented Interfaces:
TypedValueSerializer<ObjectValue>
Direct Known Subclasses:
JavaObjectSerializer

public abstract class AbstractObjectValueSerializer
extends AbstractTypedValueSerializer<ObjectValue>

Abstract implementation of a TypedValueSerializer for ObjectValues.

Author:
Daniel Meyer

Field Summary
protected  String serializationDataFormat
           
 
Fields inherited from class org.camunda.bpm.engine.impl.variable.serializer.AbstractTypedValueSerializer
valueType
 
Constructor Summary
AbstractObjectValueSerializer(String serializationDataFormat)
           
 
Method Summary
protected abstract  boolean canSerializeObject(Object value)
          return true if this serializer is able to serialize the provided object.
protected  boolean canWriteValue(TypedValue typedValue)
           
 ObjectValue convertToTypedValue(UntypedValueImpl untypedValue)
          Returns a typed value for the provided untyped value.
protected abstract  Object deserializeFromByteArray(byte[] object, String objectTypeName)
          Deserialize the object from a byte array.
protected  void dirtyCheckOnFlush(Object deserializedObject, byte[] serializedValue, ValueFields valueFields)
           
 String getSerializationDataformat()
           
protected  byte[] getSerializedBytesValue(String serializedStringValue)
           
protected  String getSerializedStringValue(byte[] serializedByteValue)
           
protected abstract  String getTypeNameForDeserialized(Object deserializedObject)
          Returns the type name for the deserialized object.
protected abstract  boolean isSerializationTextBased()
          Return true if the serialization is text based.
protected  String readObjectNameFromFields(ValueFields valueFields)
           
protected  byte[] readSerializedValueFromFields(ValueFields valueFields)
           
 ObjectValue readValue(ValueFields valueFields, boolean deserializeObjectValue)
          Retrieve a TypedValue from the provided ValueFields.
protected abstract  byte[] serializeToByteArray(Object deserializedObject)
          Implementations must return a byte[] representation of the provided object.
protected  void updateObjectValue(ObjectValueImpl objectValue, String objectTypeName, String serializedValue)
           
protected  void writeToValueFields(ValueFields valueFields, String objectTypeName, byte[] serializedValue)
           
 void writeValue(ObjectValue value, ValueFields valueFields)
          Serialize a TypedValue to the ValueFields.
 
Methods inherited from class org.camunda.bpm.engine.impl.variable.serializer.AbstractTypedValueSerializer
canHandle, getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.camunda.bpm.engine.impl.variable.serializer.TypedValueSerializer
getName
 

Field Detail

serializationDataFormat

protected String serializationDataFormat
Constructor Detail

AbstractObjectValueSerializer

public AbstractObjectValueSerializer(String serializationDataFormat)
Method Detail

getSerializationDataformat

public String getSerializationDataformat()
Specified by:
getSerializationDataformat in interface TypedValueSerializer<ObjectValue>
Overrides:
getSerializationDataformat in class AbstractTypedValueSerializer<ObjectValue>
Returns:
the dataformat used by the serializer or null if this is not an object serializer

convertToTypedValue

public ObjectValue convertToTypedValue(UntypedValueImpl untypedValue)
Description copied from interface: TypedValueSerializer
Returns a typed value for the provided untyped value. This is used on cases where the user sets an untyped value which is then detected to be handled by this TypedValueSerializer (by invocation of TypedValueSerializer.canHandle(TypedValue)).

Parameters:
untypedValue - the untyped value
Returns:
the corresponding typed value

writeValue

public void writeValue(ObjectValue value,
                       ValueFields valueFields)
Description copied from interface: TypedValueSerializer
Serialize a TypedValue to the ValueFields.

Parameters:
value - the TypedValue to persist
valueFields - the ValueFields to which the value should be persisted

readValue

public ObjectValue readValue(ValueFields valueFields,
                             boolean deserializeObjectValue)
Description copied from interface: TypedValueSerializer
Retrieve a TypedValue from the provided ValueFields.

Parameters:
valueFields - the ValueFields to retrieve the value from
deserializeObjectValue - indicates whether a SerializableValue should be deserialized.
Returns:
the TypedValue

writeToValueFields

protected void writeToValueFields(ValueFields valueFields,
                                  String objectTypeName,
                                  byte[] serializedValue)

updateObjectValue

protected void updateObjectValue(ObjectValueImpl objectValue,
                                 String objectTypeName,
                                 String serializedValue)

readObjectNameFromFields

protected String readObjectNameFromFields(ValueFields valueFields)

readSerializedValueFromFields

protected byte[] readSerializedValueFromFields(ValueFields valueFields)

getSerializedStringValue

protected String getSerializedStringValue(byte[] serializedByteValue)

getSerializedBytesValue

protected byte[] getSerializedBytesValue(String serializedStringValue)

canWriteValue

protected boolean canWriteValue(TypedValue typedValue)
Specified by:
canWriteValue in class AbstractTypedValueSerializer<ObjectValue>

dirtyCheckOnFlush

protected void dirtyCheckOnFlush(Object deserializedObject,
                                 byte[] serializedValue,
                                 ValueFields valueFields)

canSerializeObject

protected abstract boolean canSerializeObject(Object value)
return true if this serializer is able to serialize the provided object.

Parameters:
value - the object to test (guaranteed to be a non-null value)
Returns:
true if the serializer can handle the object.

getTypeNameForDeserialized

protected abstract String getTypeNameForDeserialized(Object deserializedObject)
Returns the type name for the deserialized object.

Parameters:
deserializedObject. - Guaranteed not to be null
Returns:
the type name fot the object.

serializeToByteArray

protected abstract byte[] serializeToByteArray(Object deserializedObject)
                                        throws Exception
Implementations must return a byte[] representation of the provided object. The object is guaranteed not to be null.

Parameters:
deserializedObject - the object to serialize
Returns:
the byte array value of the object
Throws:
exception - in case the object cannot be serialized
Exception

deserializeFromByteArray

protected abstract Object deserializeFromByteArray(byte[] object,
                                                   String objectTypeName)
                                            throws Exception
Deserialize the object from a byte array.

Parameters:
object - the object to deserialize
objectTypeName - the type name of the object to deserialize
Returns:
the deserialized object
Throws:
exception - in case the object cannot be deserialized
Exception

isSerializationTextBased

protected abstract boolean isSerializationTextBased()
Return true if the serialization is text based. Return false otherwise



Copyright © 2014 camunda services GmbH. All rights reserved.