users@jaxb.java.net

enum types and generated constants?

From: Dmitri Colebatch <colebatchd_at_gmail.com>
Date: Fri, 10 Jun 2005 10:32:55 +1000

Hi all,

We're in the process of migrating from XmlBeans to JAXB 2.0 and one of
the things we're missing is generated constants for enum types. I'm
hoping that this is a case of me not looking in the right place for
what I'm looking for and someone will be able to simply point me in
the right direction.

Consider a schema containing this:

        <xsd:simpleType name="ContactMethod">
                <xsd:annotation>
                        <xsd:documentation>Enumerated list of possible contact
methods.</xsd:documentation>
                </xsd:annotation>
                <xsd:restriction base="xsd:token">
                        <xsd:enumeration value="BusinessTelephone"/>
                        <xsd:enumeration value="HomeTelephone"/>
                        <xsd:enumeration value="Mobile"/>
                        <xsd:enumeration value="Fax"/>
                        <xsd:enumeration value="Email"/>
                        <xsd:enumeration value="Mail"/>
                </xsd:restriction>
        </xsd:simpleType>

JAXB generates a method

  public String getContactMethod()

which is great, but I'd like to have it generate

  public ContactMethod getContactMethod()

and

  enum ContactMethod { BusinessTelephone, HomeTelephone, ...... }

or something similar. I'm assuming others have also run into this and
am guessing that it might have already been solved. What's the common
wisdom in regards to JAXB 2.0 and schema enum types?

cheers
dim