Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
The JAXB typesafe enumeration converter allows you to automatically translate an XML element value to an appropriate typesafe enumeration value as defined in your XML schema.
For more information, see "Mappings and JAXB Typesafe Enumerations".
Table 35-14 summarizes which mappings support this option.
Table 35-14 Mapping Support for JAXB Typesafe Enumeration Converter
Mapping | Using TopLink Workbench | Using Java
|
---|---|---|
|
|
|
|
![]() |
|
EIS Composite Direct Collection Mapping |
![]() |
|
|
|
|
|
![]() |
|
XML Composite Direct Collection Mapping |
![]() |
|
Footnote 1 When used with XML records only (see "Configuring Record Format").
TopLink Workbench does not support the JAXBTypesafeEnumConverter
directly: to configure a mapping with this converter, you must use Java to create an amendment method (see "Using Java").
If you create a project and object model using the TopLink JAXB compiler (see "Creating an XML Project From an XML Schema"), the compiler will create the type safe enumeration class and a class with descriptor amendment methods and register the required amendment methods automatically (see "Typesafe Enumeration Converter Amendment Method DescriptorAfterLoads Class").
To configure a mapping with a JAXBTypesafeEnumConverter
in Java, use a descriptor amendment method (see "Configuring Amendment Methods"). Example 35-15 illustrates an amendment method that configures an XMLDirectMapping
with a JAXBTypesafeEnumConverter
. In this example, attribute _Val
is mapped to a JAXB typesafe enumeration corresponding to typesafe enumeration class MyTypesafeEnum
.
Example 35-15 Creating a JAXB Typesafe Enumeration XML Mapping
public class DescriptorAfterLoads { public static void amendRootImplDescriptor(ClassDescriptor descriptor) { DatabaseMapping _ValMapping = descriptor.getMappingForAttributeName("_Val"); JAXBTypesafeEnumConverter _ValConverter = new JAXBTypesafeEnumConverter(); ValConverter.setEnumClassName("MyTypesafeEnum"); ((XMLDirectMapping) _ValMapping).setConverter(_ValConverter); } }