Class SerializedObjectConverter
- java.lang.Object
-
- org.eclipse.persistence.mappings.converters.SerializedObjectConverter
-
- All Implemented Interfaces:
java.io.Serializable,CoreConverter<DatabaseMapping,Session>,org.eclipse.persistence.internal.descriptors.ClassNameConversionRequired,Converter
public class SerializedObjectConverter extends java.lang.Object implements Converter, org.eclipse.persistence.internal.descriptors.ClassNameConversionRequired
Purpose: The serialized object converter can be used to store an arbitrary object or set of objects into a database binary or character field. By default it uses the Java serializer so the target must be serializable. A custom Serializer can also be specified, such as XML or JSON.
- See Also:
Serializer,XMLSerializer,JSONSerializer, Serialized Form- Author:
- James Sutherland
- Since:
- OracleAS TopLink 10g (10.0.3)
-
-
Field Summary
Fields Modifier and Type Field Description protected DatabaseMappingmappingprotected Serializerserializerprotected java.lang.StringserializerClassNameprotected java.lang.StringserializerPackage
-
Constructor Summary
Constructors Constructor Description SerializedObjectConverter()PUBLIC: Default constructor.SerializedObjectConverter(DatabaseMapping mapping)PUBLIC: Default constructor.SerializedObjectConverter(DatabaseMapping mapping, java.lang.String serializerClassName)PUBLIC: Default constructor.SerializedObjectConverter(DatabaseMapping mapping, Serializer serializer)PUBLIC: Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconvertClassNamesToClasses(java.lang.ClassLoader classLoader)INTERNAL: Convert all the class-name-based settings in this converter to actual class-based settings.java.lang.ObjectconvertDataValueToObjectValue(java.lang.Object fieldValue, Session session)INTERNAL: The fieldValue will be a byte array.java.lang.ObjectconvertObjectValueToDataValue(java.lang.Object attributeValue, Session session)INTERNAL: Convert the object to a byte array through serialize.protected DatabaseMappinggetMapping()INTERNAL: Return the mapping.SerializergetSerializer()Return the serialize used for this converter.java.lang.StringgetSerializerClassName()Return the class name of the serializer.java.lang.StringgetSerializerPackage()Return the package used for XML and JSON serialization JAXBContext.voidinitialize(DatabaseMapping mapping, Session session)INTERNAL: Set the mapping.booleanisMutable()INTERNAL: If the converter converts the value to a non-atomic value, i.e.voidsetSerializer(Serializer serializer)Set the serialize used for this converter.voidsetSerializerClassName(java.lang.String serializerClassName)Set the class name of the serializer.voidsetSerializerPackage(java.lang.String serializerPackage)Set the package used for XML and JSON serialization JAXBContext.
-
-
-
Field Detail
-
mapping
protected DatabaseMapping mapping
-
serializer
protected Serializer serializer
-
serializerClassName
protected java.lang.String serializerClassName
-
serializerPackage
protected java.lang.String serializerPackage
-
-
Constructor Detail
-
SerializedObjectConverter
public SerializedObjectConverter()
PUBLIC: Default constructor.
-
SerializedObjectConverter
public SerializedObjectConverter(DatabaseMapping mapping)
PUBLIC: Default constructor.
-
SerializedObjectConverter
public SerializedObjectConverter(DatabaseMapping mapping, Serializer serializer)
PUBLIC: Default constructor.
-
SerializedObjectConverter
public SerializedObjectConverter(DatabaseMapping mapping, java.lang.String serializerClassName)
PUBLIC: Default constructor.
-
-
Method Detail
-
convertClassNamesToClasses
public void convertClassNamesToClasses(java.lang.ClassLoader classLoader)
INTERNAL: Convert all the class-name-based settings in this converter to actual class-based settings. This method is used when converting a project that has been built with class names to a project with classes. This method is implemented by subclasses as necessary.- Specified by:
convertClassNamesToClassesin interfaceorg.eclipse.persistence.internal.descriptors.ClassNameConversionRequired- Parameters:
classLoader-
-
convertDataValueToObjectValue
public java.lang.Object convertDataValueToObjectValue(java.lang.Object fieldValue, Session session) throws DescriptorExceptionINTERNAL: The fieldValue will be a byte array. Create a ByteArrayInputStream on the fieldValue. Create an ObjectInputStream on the ByteArrayInputStream to read in the objects.- Specified by:
convertDataValueToObjectValuein interfaceConverter- Specified by:
convertDataValueToObjectValuein interfaceCoreConverter<DatabaseMapping,Session>- Throws:
DescriptorException
-
convertObjectValueToDataValue
public java.lang.Object convertObjectValueToDataValue(java.lang.Object attributeValue, Session session)INTERNAL: Convert the object to a byte array through serialize.- Specified by:
convertObjectValueToDataValuein interfaceConverter- Specified by:
convertObjectValueToDataValuein interfaceCoreConverter<DatabaseMapping,Session>
-
initialize
public void initialize(DatabaseMapping mapping, Session session)
INTERNAL: Set the mapping.- Specified by:
initializein interfaceConverter- Specified by:
initializein interfaceCoreConverter<DatabaseMapping,Session>
-
getMapping
protected DatabaseMapping getMapping()
INTERNAL: Return the mapping.
-
isMutable
public boolean isMutable()
INTERNAL: If the converter converts the value to a non-atomic value, i.e. a value that can have its' parts changed without being replaced, then it must return false, serialization can be non-atomic.
-
getSerializer
public Serializer getSerializer()
Return the serialize used for this converter.
-
setSerializer
public void setSerializer(Serializer serializer)
Set the serialize used for this converter.
-
getSerializerClassName
public java.lang.String getSerializerClassName()
Return the class name of the serializer.
-
setSerializerClassName
public void setSerializerClassName(java.lang.String serializerClassName)
Set the class name of the serializer.
-
getSerializerPackage
public java.lang.String getSerializerPackage()
Return the package used for XML and JSON serialization JAXBContext.
-
setSerializerPackage
public void setSerializerPackage(java.lang.String serializerPackage)
Set the package used for XML and JSON serialization JAXBContext.
-
-