Class AbstractSerializableValueSerializer<T extends SerializableValue>

java.lang.Object
org.operaton.bpm.engine.impl.variable.serializer.AbstractTypedValueSerializer<T>
org.operaton.bpm.engine.impl.variable.serializer.AbstractSerializableValueSerializer<T>
Type Parameters:
T - the type of the serializable value
All Implemented Interfaces:
TypedValueSerializer<T>
Direct Known Subclasses:
AbstractObjectValueSerializer, SpinValueSerializer

public abstract class AbstractSerializableValueSerializer<T extends SerializableValue> extends AbstractTypedValueSerializer<T>
Abstract base class for serializers that handle serializable values. Provides common functionality for serialization and deserialization of objects.
Author:
Roman Smirnov
  • Field Details

    • serializationDataFormat

      protected String serializationDataFormat
  • Constructor Details

    • AbstractSerializableValueSerializer

      protected AbstractSerializableValueSerializer(SerializableValueType type, String serializationDataFormat)
      Constructor to initialize the serializer with a specific value type and data format.
      Parameters:
      type - the type of the serializable value
      serializationDataFormat - the data format used for serialization
  • Method Details

    • getSerializationDataformat

      public String getSerializationDataformat()
      Returns the serialization data format used by this serializer.
      Specified by:
      getSerializationDataformat in interface TypedValueSerializer<T extends SerializableValue>
      Overrides:
      getSerializationDataformat in class AbstractTypedValueSerializer<T extends SerializableValue>
      Returns:
      the serialization data format
    • writeValue

      public void writeValue(T value, ValueFields valueFields)
      Serializes the given value and writes it to the provided value fields.
      Parameters:
      value - the value to serialize
      valueFields - the fields to write the serialized value to
    • readValue

      public T readValue(ValueFields valueFields, boolean deserializeObjectValue, boolean asTransientValue)
      Reads and deserializes a value from the provided value fields.
      Parameters:
      valueFields - the fields containing the serialized value
      deserializeObjectValue - whether to deserialize the object value
      asTransientValue - whether the value is transient
      Returns:
      the deserialized value
    • createDeserializedValue

      protected abstract T createDeserializedValue(Object deserializedObject, String serializedStringValue, ValueFields valueFields, boolean asTransientValue)
      Creates a deserialized value from the given parameters.
      Parameters:
      deserializedObject - the deserialized object
      serializedStringValue - the serialized string representation
      valueFields - the value fields
      asTransientValue - whether the value is transient
      Returns:
      the deserialized value
    • createSerializedValue

      protected abstract T createSerializedValue(String serializedStringValue, ValueFields valueFields, boolean asTransientValue)
      Creates a serialized value from the given parameters.
      Parameters:
      serializedStringValue - the serialized string representation
      valueFields - the value fields
      asTransientValue - whether the value is transient
      Returns:
      the serialized value
    • writeToValueFields

      protected abstract void writeToValueFields(T value, ValueFields valueFields, byte[] serializedValue)
      Writes the serialized value to the provided value fields.
      Parameters:
      value - the value to write
      valueFields - the fields to write to
      serializedValue - the serialized value as a byte array
    • updateTypedValue

      protected abstract void updateTypedValue(T value, String serializedStringValue)
      Updates the typed value with the serialized string representation.
      Parameters:
      value - the typed value to update
      serializedStringValue - the serialized string representation
    • readSerializedValueFromFields

      protected byte[] readSerializedValueFromFields(ValueFields valueFields)
      Reads the serialized value from the provided value fields as a byte array.
      Parameters:
      valueFields - the fields containing the serialized value
      Returns:
      the serialized value as a byte array
    • getSerializedStringValue

      protected String getSerializedStringValue(byte[] serializedByteValue)
      Converts a byte array to a serialized string representation.
      Parameters:
      serializedByteValue - the byte array to convert
      Returns:
      the serialized string representation
    • getSerializedBytesValue

      protected byte[] getSerializedBytesValue(String serializedStringValue)
      Converts a serialized string representation to a byte array.
      Parameters:
      serializedStringValue - the string to convert
      Returns:
      the byte array representation
    • canWriteValue

      protected boolean canWriteValue(TypedValue typedValue)
      Checks if the serializer can write the given typed value.
      Specified by:
      canWriteValue in class AbstractTypedValueSerializer<T extends SerializableValue>
      Parameters:
      typedValue - the value to check
      Returns:
      true if the serializer can write the value, false otherwise
    • canSerializeValue

      protected abstract boolean canSerializeValue(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.
    • 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
    • deserializeFromByteArray

      protected abstract Object deserializeFromByteArray(byte[] object, ValueFields valueFields) throws Exception
      Deserialize the object from a byte array.
      Parameters:
      object - the object to deserialize
      valueFields - the value fields
      Returns:
      the deserialized object
      Throws:
      Exception - in case the object cannot be deserialized
    • isSerializationTextBased

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