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 Summary
FieldsFields inherited from class org.operaton.bpm.engine.impl.variable.serializer.AbstractTypedValueSerializer
BINARY_VALUE_TYPES, valueType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSerializableValueSerializer(SerializableValueType type, String serializationDataFormat) Constructor to initialize the serializer with a specific value type and data format. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract booleancanSerializeValue(Object value) return true if this serializer is able to serialize the provided object.protected booleancanWriteValue(TypedValue typedValue) Checks if the serializer can write the given typed value.protected abstract TcreateDeserializedValue(Object deserializedObject, String serializedStringValue, ValueFields valueFields, boolean asTransientValue) Creates a deserialized value from the given parameters.protected abstract TcreateSerializedValue(String serializedStringValue, ValueFields valueFields, boolean asTransientValue) Creates a serialized value from the given parameters.protected abstract ObjectdeserializeFromByteArray(byte[] object, ValueFields valueFields) Deserialize the object from a byte array.Returns the serialization data format used by this serializer.protected byte[]getSerializedBytesValue(String serializedStringValue) Converts a serialized string representation to a byte array.protected StringgetSerializedStringValue(byte[] serializedByteValue) Converts a byte array to a serialized string representation.protected abstract booleanReturn true if the serialization is text based.protected byte[]readSerializedValueFromFields(ValueFields valueFields) Reads the serialized value from the provided value fields as a byte array.readValue(ValueFields valueFields, boolean deserializeObjectValue, boolean asTransientValue) Reads and deserializes a value from the provided value fields.protected abstract byte[]serializeToByteArray(Object deserializedObject) Implementations must return a byte[] representation of the provided object.protected abstract voidupdateTypedValue(T value, String serializedStringValue) Updates the typed value with the serialized string representation.protected abstract voidwriteToValueFields(T value, ValueFields valueFields, byte[] serializedValue) Writes the serialized value to the provided value fields.voidwriteValue(T value, ValueFields valueFields) Serializes the given value and writes it to the provided value fields.Methods inherited from class org.operaton.bpm.engine.impl.variable.serializer.AbstractTypedValueSerializer
canHandle, getType, isMutableValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.operaton.bpm.engine.impl.variable.serializer.TypedValueSerializer
convertToTypedValue, getName
-
Field Details
-
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 valueserializationDataFormat- the data format used for serialization
-
-
Method Details
-
getSerializationDataformat
Returns the serialization data format used by this serializer.- Specified by:
getSerializationDataformatin interfaceTypedValueSerializer<T extends SerializableValue>- Overrides:
getSerializationDataformatin classAbstractTypedValueSerializer<T extends SerializableValue>- Returns:
- the serialization data format
-
writeValue
Serializes the given value and writes it to the provided value fields.- Parameters:
value- the value to serializevalueFields- 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 valuedeserializeObjectValue- whether to deserialize the object valueasTransientValue- 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 objectserializedStringValue- the serialized string representationvalueFields- the value fieldsasTransientValue- 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 representationvalueFields- the value fieldsasTransientValue- 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 writevalueFields- the fields to write toserializedValue- the serialized value as a byte array
-
updateTypedValue
Updates the typed value with the serialized string representation.- Parameters:
value- the typed value to updateserializedStringValue- the serialized string representation
-
readSerializedValueFromFields
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
Converts a byte array to a serialized string representation.- Parameters:
serializedByteValue- the byte array to convert- Returns:
- the serialized string representation
-
getSerializedBytesValue
Converts a serialized string representation to a byte array.- Parameters:
serializedStringValue- the string to convert- Returns:
- the byte array representation
-
canWriteValue
Checks if the serializer can write the given typed value.- Specified by:
canWriteValuein classAbstractTypedValueSerializer<T extends SerializableValue>- Parameters:
typedValue- the value to check- Returns:
- true if the serializer can write the value, false otherwise
-
canSerializeValue
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
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 deserializevalueFields- 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
-