|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.alfresco.repo.domain.propval.DefaultPropertyTypeConverter
public class DefaultPropertyTypeConverter
Default converter for handling data going to and from the persistence layer.
Properties are stored as a set of well-defined types defined by the enumerationPropertyValueEntity.PersistedType
. Ultimately, data can be persisted as BLOB data, but must
be the last resort.
Field Summary | |
---|---|
protected static java.util.Map |
defaultPersistedTypesByClass
An unmodifiable map of types and how they should be persisted |
Constructor Summary | |
---|---|
DefaultPropertyTypeConverter()
Default constructor |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.util.Map defaultPersistedTypesByClass
Constructor Detail |
---|
public DefaultPropertyTypeConverter()
Method Detail |
---|
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 check
public java.io.Serializable constructInstance(java.lang.String clazzName)
PropertyValueEntity.PersistedType.CONSTRUCTABLE
.
constructInstance
in interface PropertyTypeConverter
clazzName
- the name of the class
public 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.LONG
PropertyValueEntity.PersistedType.DOUBLE
PropertyValueEntity.PersistedType.STRING
PropertyValueEntity.PersistedType.SERIALIZABLE
PropertyValueEntity.PersistedType.CONSTRUCTABLE
PropertyValueEntity.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 PropertyTypeConverter
value
- the value that does not have an obvious persistence slot
public java.lang.Object convert(java.lang.Class targetClass, java.io.Serializable value)
DefaultTypeConverter
but also adds
special handling for enum types
.
convert
in interface PropertyTypeConverter
targetClass
- the desired type to convert tovalue
- the value to convert
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |