users@jaxb.java.net

Re: enum types and generated constants?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 13 Jun 2005 19:32:43 -0400

Dmitri Colebatch wrote:
> 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.

In 1.0, by default, we bind simpleTypes to type-safe enums only if it's
derived from NCName. You can change this by using a customization like
this to include xsd:token as a potential candidate for the type-safe
enum binding:

     <jaxb:globalBindings typesafeEnumBase="xsd:token" />

See some of the bundled samples for how to add <globalBindings>
customization.


In 2.0, this usability issue is fixed, and I just confirmed that it does
generate an enum class out of the box for your simple type.


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com