EclipseLink 2.0.0, build 'v20091127-r5931' API Reference

org.eclipse.persistence.mappings.converters
Class EnumTypeConverter

java.lang.Object
  extended by org.eclipse.persistence.mappings.converters.ObjectTypeConverter
      extended by 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.

See Also:
Serialized Form
Author:
Guy Pelletier
Since:
Toplink 10.1.4RI

Field Summary
 
Fields inherited from class org.eclipse.persistence.mappings.converters.ObjectTypeConverter
attributeToFieldValues, defaultAttributeValue, fieldClassification, fieldClassificationName, fieldToAttributeValues, mapping
 
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.
 
Method Summary
 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 Enum object to the data value.
 
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
 

Constructor Detail

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)
PUBLIC: Creating an enum converter this way expects that you will provide the conversion values separately.

Method Detail

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

EclipseLink 2.0.0, build 'v20091127-r5931' API Reference