Skip navigation links
org.eclipse.persistence.mappings.converters
Class EnumTypeConverter
java.lang.Object
org.eclipse.persistence.mappings.converters.ObjectTypeConverter
org.eclipse.persistence.mappings.converters.EnumTypeConverter
- All Implemented Interfaces:
- java.io.Serializable, Converter
-
public class EnumTypeConverter
- extends ObjectTypeConverter
Purpose: Object type converter is used to match a fixed number of database data values to a Java enum 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.
- Since:
- Toplink 10.1.4RI
- Author:
- Guy Pelletier
- See Also:
- Serialized Form
Constructor Summary |
EnumTypeConverter(DatabaseMapping mapping, java.lang.Class enumClass, boolean useOrdinalValues)
PUBLIC: Creating an enum converter this way will create the conversion values for you using ordinal or name values. |
EnumTypeConverter(DatabaseMapping mapping, java.lang.String enumClassName)
PUBLIC: Creating an enum converter this way expects that you will provide the conversion values separately. |
EnumTypeConverter(DatabaseMapping mapping, java.lang.String enumClassName, boolean useOrdinalValues)
PUBLIC: Creating an enum converter this way will create the conversion values for you using ordinal or name values. |
Methods inherited from class org.eclipse.persistence.mappings.converters.ObjectTypeConverter |
addConversionValue, addToAttributeOnlyConversionValue, getAttributeToFieldValues, getDefaultAttributeValue, getFieldClassification, getFieldClassification, getFieldClassificationName, getFieldToAttributeValueAssociations, getFieldToAttributeValues, getMapping, initialize, initializeFieldClassification, isMutable, mapBooleans, mapGenders, mapResponses, setAttributeToFieldValues, setDefaultAttributeValue, setFieldClassification, setFieldClassificationName, setFieldToAttributeValueAssociations, setFieldToAttributeValues, setMapping |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_enumClass
private java.lang.Class m_enumClass
m_enumClassName
private java.lang.String m_enumClassName
m_useOrdinalValues
private boolean m_useOrdinalValues
EnumTypeConverter
public EnumTypeConverter(DatabaseMapping mapping,
java.lang.Class enumClass,
boolean useOrdinalValues)
- PUBLIC: Creating an enum converter this way will create the conversion values for you using ordinal or name values.
EnumTypeConverter
public EnumTypeConverter(DatabaseMapping mapping,
java.lang.String enumClassName,
boolean useOrdinalValues)
- PUBLIC: Creating an enum converter this way will create the conversion values for you using ordinal or name values.
EnumTypeConverter
public EnumTypeConverter(DatabaseMapping mapping,
java.lang.String enumClassName)
- PUBLIC: Creating an enum converter this way expects that you will provide the conversion values separately.
initializeConversions
protected void initializeConversions(java.lang.Class enumClass)
getEnumClass
public java.lang.Class getEnumClass()
getEnumClassName
public java.lang.String getEnumClassName()
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.
-
- Overrides:
convertClassNamesToClasses
in class ObjectTypeConverter
-
- Parameters:
classLoader
-
convertDataValueToObjectValue
public java.lang.Object convertDataValueToObjectValue(java.lang.Object fieldValue,
Session session)
- INTERNAL: Returns the corresponding attribute value for the specified field value. Wraps the super method to return an Enum type from the string conversion.
-
- Specified by:
convertDataValueToObjectValue
in interface Converter
- Overrides:
convertDataValueToObjectValue
in class ObjectTypeConverter
convertObjectValueToDataValue
public java.lang.Object convertObjectValueToDataValue(java.lang.Object attributeValue,
Session session)
- INTERNAL: Convert Enum object to the data value. Internal enums are stored as strings (names) so this method wraps the super method in that if breaks down the enum to a string name before converting it.
-
- Specified by:
convertObjectValueToDataValue
in interface Converter
- Overrides:
convertObjectValueToDataValue
in class ObjectTypeConverter
Skip navigation links