|
EclipseLink 2.4.2, build 'v20130514-5956486' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.persistence.mappings.converters.ObjectTypeConverter
public class ObjectTypeConverter
Purpose: Object type converter is used to match a fixed number of database data values to Java object value. It can be used when the values on the database and in the Java differ. To create an object type converter, simply specify the set of conversion value pairs. A default value and one-way conversion are also supported for legacy data situations.
Field Summary | |
---|---|
protected java.util.Map<java.lang.String,java.lang.String> |
addToAttributeOnlyConversionValueStrings
|
protected java.util.Map |
attributeToFieldValues
|
protected java.util.Map<java.lang.String,java.lang.String> |
conversionValueStrings
|
protected java.lang.String |
converterName
|
protected java.lang.Class |
dataType
|
protected java.lang.String |
dataTypeName
|
protected java.lang.Object |
defaultAttributeValue
|
protected java.lang.String |
defaultAttributeValueString
|
protected java.lang.Class |
fieldClassification
|
protected java.lang.String |
fieldClassificationName
|
protected java.util.Map |
fieldToAttributeValues
|
protected DatabaseMapping |
mapping
|
protected java.lang.Class |
objectType
|
protected java.lang.String |
objectTypeName
|
Constructor Summary | |
---|---|
ObjectTypeConverter()
PUBLIC: Default constructor. |
|
ObjectTypeConverter(DatabaseMapping mapping)
PUBLIC: Default constructor. |
Method Summary | |
---|---|
void |
addConversionValue(java.lang.Object fieldValue,
java.lang.Object attributeValue)
PUBLIC: A type conversion value is a two-way mapping from the database to the object. |
void |
addConversionValueStrings(java.lang.String dataValue,
java.lang.String objectValue)
INTERNAL: Set from JPA processing where we deal with strings only to avoid class loader conflicts. |
void |
addToAttributeOnlyConversionValue(java.lang.Object fieldValue,
java.lang.Object attributeValue)
PUBLIC: An attribute only conversion value is a one-way mapping from the database to the object. |
void |
addToAttributeOnlyConversionValueStrings(java.lang.String dataValue,
java.lang.String objectValue)
INTERNAL: Set from JPA processing where we deal with strings only to avoid class loader conflicts. |
void |
convertClassNamesToClasses(java.lang.ClassLoader classLoader)
INTERNAL: Convert all the class-name-based settings in this converter to actual class-based settings. |
java.lang.Object |
convertDataValueToObjectValue(java.lang.Object fieldValue,
Session session)
INTERNAL: Returns the corresponding attribute value for the specified field value. |
java.lang.Object |
convertObjectValueToDataValue(java.lang.Object attributeValue,
Session session)
INTERNAL: Convert to the data value. |
java.util.Map |
getAttributeToFieldValues()
INTERNAL: Get the attribute to field mapping. |
java.lang.Object |
getDefaultAttributeValue()
PUBLIC: The default value can be used if the database can possibly store additional values then those that have been mapped. |
java.lang.Class |
getFieldClassification()
INTERNAL: Get the type of the field value to allow conversion from the database. |
java.lang.Class |
getFieldClassification(org.eclipse.persistence.internal.helper.DatabaseField fieldToClassify)
INTERNAL: Return the classifiction for the field contained in the mapping. |
java.lang.String |
getFieldClassificationName()
|
java.util.Vector |
getFieldToAttributeValueAssociations()
INTERNAL: Return a collection of the field to attribute value associations. |
java.util.Map |
getFieldToAttributeValues()
INTERNAL: Get the field to attribute mapping. |
protected DatabaseMapping |
getMapping()
INTERNAL: Return the mapping. |
void |
initialize(DatabaseMapping mapping,
Session session)
INTERNAL: Set the mapping. |
void |
initializeFieldClassification(Session session)
INTERNAL: Set the field classification through searching the fields map. |
boolean |
isMutable()
INTERNAL: If the converter converts the value to a non-atomic value, i.e. |
protected java.lang.Class |
loadClass(java.lang.String className,
java.lang.ClassLoader classLoader)
Load the given class name with the given loader. |
void |
mapBooleans()
PUBLIC: This is a very specific protocol which maps fieldValues "T" and "F" to true and false respectively. |
void |
mapGenders()
PUBLIC: This is a very specific protocol which maps fieldValues "F" and "M" to "Female" and "Male" respectively. |
void |
mapResponses()
PUBLIC: This is a very specific protocol which maps fieldValues "Y" and "N" to "Yes" and "No" respectively. |
void |
setAttributeToFieldValues(java.util.Map attributeToFieldValues)
INTERNAL: Set the attribute to field mapping. |
void |
setConverterName(java.lang.String converterName)
INTERNAL: Set from JPA processing where we deal with strings only to avoid class loader conflicts. |
void |
setDataTypeName(java.lang.String dataTypeName)
INTERNAL: Set from JPA processing where we deal with strings only to avoid class loader conflicts. |
void |
setDefaultAttributeValue(java.lang.Object defaultAttributeValue)
PUBLIC: The default value can be used if the database can possibly store additional values then those that have been mapped. |
void |
setDefaultAttributeValueString(java.lang.String defaultAttributeValueString)
INTERNAL: Set from JPA processing where we deal with strings only to avoid class loader conflicts. |
void |
setFieldClassification(java.lang.Class fieldClassification)
INTERNAL: Set the type of the field value to allow conversion from the database. |
void |
setFieldClassificationName(java.lang.String fieldClassificationName)
|
void |
setFieldToAttributeValueAssociations(java.util.Vector fieldToAttributeValueAssociations)
INTERNAL: Set a collection of the field to attribute value associations. |
void |
setFieldToAttributeValues(java.util.Map fieldToAttributeValues)
INTERNAL: Set the field to attribute mapping. |
protected void |
setMapping(DatabaseMapping mapping)
INTERNAL: Set the mapping. |
void |
setObjectTypeName(java.lang.String objectTypeName)
INTERNAL: Set from JPA processing where we deal with strings only to avoid class loader conflicts. |
protected void |
throwInitObjectException(java.lang.Exception exception,
java.lang.Class type,
java.lang.String value,
boolean isData)
INTERNAL: |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String converterName
protected java.lang.Class dataType
protected java.lang.String dataTypeName
protected java.lang.Class objectType
protected java.lang.String objectTypeName
protected java.util.Map<java.lang.String,java.lang.String> conversionValueStrings
protected java.util.Map<java.lang.String,java.lang.String> addToAttributeOnlyConversionValueStrings
protected DatabaseMapping mapping
protected transient java.util.Map fieldToAttributeValues
protected java.util.Map attributeToFieldValues
protected transient java.lang.Object defaultAttributeValue
protected transient java.lang.String defaultAttributeValueString
protected transient java.lang.Class fieldClassification
protected transient java.lang.String fieldClassificationName
Constructor Detail |
---|
public ObjectTypeConverter()
public ObjectTypeConverter(DatabaseMapping mapping)
Method Detail |
---|
public void addConversionValue(java.lang.Object fieldValue, java.lang.Object attributeValue)
public void addConversionValueStrings(java.lang.String dataValue, java.lang.String objectValue)
public void addToAttributeOnlyConversionValue(java.lang.Object fieldValue, java.lang.Object attributeValue)
public void addToAttributeOnlyConversionValueStrings(java.lang.String dataValue, java.lang.String objectValue)
public java.util.Map getAttributeToFieldValues()
public void convertClassNamesToClasses(java.lang.ClassLoader classLoader)
classLoader
- protected java.lang.Class loadClass(java.lang.String className, java.lang.ClassLoader classLoader)
public java.lang.Object convertDataValueToObjectValue(java.lang.Object fieldValue, Session session)
convertDataValueToObjectValue
in interface Converter
public java.lang.Object getDefaultAttributeValue()
protected DatabaseMapping getMapping()
protected void setMapping(DatabaseMapping mapping)
public void setObjectTypeName(java.lang.String objectTypeName)
public java.lang.Class getFieldClassification()
public java.lang.String getFieldClassificationName()
public java.lang.Class getFieldClassification(org.eclipse.persistence.internal.helper.DatabaseField fieldToClassify)
public java.util.Vector getFieldToAttributeValueAssociations()
public java.util.Map getFieldToAttributeValues()
public java.lang.Object convertObjectValueToDataValue(java.lang.Object attributeValue, Session session)
convertObjectValueToDataValue
in interface Converter
public void mapBooleans()
public void mapGenders()
public void mapResponses()
public void initializeFieldClassification(Session session) throws DescriptorException
DescriptorException
public void initialize(DatabaseMapping mapping, Session session)
initialize
in interface Converter
public void setAttributeToFieldValues(java.util.Map attributeToFieldValues)
public void setConverterName(java.lang.String converterName)
public void setDataTypeName(java.lang.String dataTypeName)
public void setDefaultAttributeValue(java.lang.Object defaultAttributeValue)
public void setDefaultAttributeValueString(java.lang.String defaultAttributeValueString)
public void setFieldClassification(java.lang.Class fieldClassification)
public void setFieldClassificationName(java.lang.String fieldClassificationName)
public void setFieldToAttributeValueAssociations(java.util.Vector fieldToAttributeValueAssociations)
public void setFieldToAttributeValues(java.util.Map fieldToAttributeValues)
public boolean isMutable()
isMutable
in interface Converter
protected void throwInitObjectException(java.lang.Exception exception, java.lang.Class type, java.lang.String value, boolean isData)
|
EclipseLink 2.4.2, build 'v20130514-5956486' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |