public class DefaultPropertyTypeConverter extends java.lang.Object implements PropertyTypeConverter
PropertyValueEntity.PersistedType. Ultimately, data can be persisted as BLOB data, but must
be the last resort.| Modifier and Type | Field and Description |
|---|---|
protected static java.util.Map |
defaultPersistedTypesByClass
An unmodifiable map of types and how they should be persisted
|
| Constructor and Description |
|---|
DefaultPropertyTypeConverter()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addTypeMapping(java.lang.Class clazz,
PropertyValueEntity.PersistedType targetType)
Allow subclasses to add further type mappings specific to the implementation
|
java.io.Serializable |
constructInstance(java.lang.String clazzName)
Construct an instance of an object that was deemed to be
PropertyValueEntity.PersistedType.CONSTRUCTABLE. |
java.lang.Object |
convert(java.lang.Class targetClass,
java.io.Serializable value)
Performs the conversion using
DefaultTypeConverter but also adds
special handling for enum types. |
PropertyValueEntity.PersistedType |
getPersistentType(java.io.Serializable value)
When external to persisted type mappings are not obvious, the persistence framework,
before persisting as
PropertyValueEntity.PersistedType.SERIALIZABLE, will give the converter
a chance to choose how the value must be persisted:
PropertyValueEntity.PersistedType.LONG
PropertyValueEntity.PersistedType.DOUBLE
PropertyValueEntity.PersistedType.STRING
PropertyValueEntity.PersistedType.SERIALIZABLE
PropertyValueEntity.PersistedType.CONSTRUCTABLE
The converter should return PropertyValueEntity.PersistedType.SERIALIZABLE if no further conversions
are possible. |
protected boolean |
isConstructable(java.io.Serializable value)
Determines if the value can be adequately recreated (to equality) by creating
a new instance.
|
protected static final java.util.Map defaultPersistedTypesByClass
public DefaultPropertyTypeConverter()
protected void addTypeMapping(java.lang.Class clazz,
PropertyValueEntity.PersistedType targetType)
clazz - the class to be convertedtargetType - the target persisted typeprotected boolean isConstructable(java.io.Serializable value)
Subclasses can override this to handle any well-known types, and in conjunction with
DefaultPropertyTypeConverter.constructInstance(String), even choose to return true if it needs a
non-default constructor.
value - the value to checkpublic java.io.Serializable constructInstance(java.lang.String clazzName)
PropertyValueEntity.PersistedType.CONSTRUCTABLE.constructInstance in interface PropertyTypeConverterclazzName - the name of the classpublic PropertyValueEntity.PersistedType getPersistentType(java.io.Serializable value)
PropertyValueEntity.PersistedType.SERIALIZABLE, will give the converter
a chance to choose how the value must be persisted:
PropertyValueEntity.PersistedType.LONGPropertyValueEntity.PersistedType.DOUBLEPropertyValueEntity.PersistedType.STRINGPropertyValueEntity.PersistedType.SERIALIZABLEPropertyValueEntity.PersistedType.CONSTRUCTABLEPropertyValueEntity.PersistedType.SERIALIZABLE if no further conversions
are possible. Implicit in the return value is the converter's ability to do the
conversion when required.
If the converter can fully reconstruct an equal instance using just the name of the value's
class, then PropertyValueEntity.PersistedType.CONSTRUCTABLE can be used.getPersistentType in interface PropertyTypeConvertervalue - the value that does not have an obvious persistence slotpublic java.lang.Object convert(java.lang.Class targetClass,
java.io.Serializable value)
DefaultTypeConverter but also adds
special handling for enum types.convert in interface PropertyTypeConvertertargetClass - the desired type to convert tovalue - the value to convertCopyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.