com.abra.j2xb.annotations
Annotation Type MOEnumXmlName


@Target(value=FIELD)
@Retention(value=RUNTIME)
public @interface MOEnumXmlName

Defines the XML name used for an enumeration constant.

When mapping a Java 5 enumeration to XML, the default constant names of the XML enumerations match the Java constant names. This annotation allows to control the XML constant names, replacing the Java names with whatever names more appropriate for the XML representation.

Example

For the following enumeration
 @MOXmlGlobalType("EmployeeTypeType")
 @MOXmlNamespaceRef(Employee.class)
 public enum EmployeeType {
   commonEmployee,
   manager,
   vicePresident
 }
 

The following XML schema fragment is generated

 <xs:simpleType name="EmployeeTypeType">
   <xs:restriction base="xs:string">
     <xs:enumeration value="vicePresident"/>
     <xs:enumeration value="commonEmployee"/>
     <xs:enumeration value="manager"/>
   </xs:restriction>
 </xs:simpleType>
 

By adding this annotation, we can control the names of the enumerations in the XML representation. For instance, using

 @MOXmlGlobalType("EmployeeTypeType")
 @MOXmlNamespaceRef(Employee.class)
 public enum EmployeeType {
   commonEmployee,
   manager,
   @MOEnumXmlName("vp") vicePresident
 }
 

results in the following schema fragment

 <xs:simpleType name="EmployeeTypeType">
   <xs:restriction base="xs:string">
     <xs:enumeration value="vp"/>
     <xs:enumeration value="commonEmployee"/>
     <xs:enumeration value="manager"/>
   </xs:restriction>
 </xs:simpleType>
 

Since:
JDK1.5
Version:
1.0, May 1, 2008
Author:
Yoav Abrahami

Required Element Summary
 java.lang.String value
           
 

Element Detail

value

public abstract java.lang.String value


Copyright © 2008. All Rights Reserved.