org.alfresco.repo.domain.propval
Interface PropertyTypeConverter

All Known Implementing Classes:
DefaultPropertyTypeConverter

public interface PropertyTypeConverter

Interface for converters that to translate between persisted values and external values.

Implementations must be able to convert between values being stored and Long, Double, String - and back again.

Since:
3.2

Method Summary
 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)
          Convert a value to a given type.
 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.
 

Method Detail

getPersistentType

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: The converter should return 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.

Parameters:
value - the value that does not have an obvious persistence slot
Returns:
Returns the type of persistence to use

convert

java.lang.Object convert(java.lang.Class targetClass,
                         java.io.Serializable value)
Convert a value to a given type.

Parameters:
targetClass - the desired type to convert to
value - the value to convert
Returns:
Returns the persisted type and value to persist

constructInstance

java.io.Serializable constructInstance(java.lang.String clazzName)
Construct an instance of an object that was deemed to be PropertyValueEntity.PersistedType.CONSTRUCTABLE.

Parameters:
clazzName - the name of the class
Returns:
Returns the new instance


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.