users@jaxb.java.net

Re: Generate enum?

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Mon, 19 Dec 2011 10:03:47 +0100

Hi,

> but an enum is generated automatically for a schema type definition like this
> (or was there anything else in the original email, and where did it
> come from - I haven't seen it in my inbox?)

I though the question was about how to force the generated enum to
implement a certain interface.
Maybe I misinterpreted.

Bye,
/lexi
>
> -W
>
>
> On 18 December 2011 22:27, Aleksei Valikov <valikov_at_gmx.net> wrote:
>> Hi,
>>
>>
>>> We have some places where we do something like:
>>>      <xs:element name="Status">
>>>        <xs:simpleType>
>>>          <xs:restriction base="xs:string">
>>>            <xs:enumeration value="APPROVED" />
>>>            <xs:enumeration value="UNDECIDED" />
>>>            <xs:enumeration value="REJECTED" />
>>>          </xs:restriction>
>>>        </xs:simpleType>
>>>      </xs:element>
>>>
>>> Is there any way to have a java enum or interface or class generated
>>> for those constants?
>>
>> I think the inheritance plugin must be able to do this.
>>
>> http://confluence.highsource.org/display/J2B/Inheritance+plugin
>>
>> See
>> * https://svn.java.net/svn/jaxb2-commons~svn/basics/trunk/tests/issues/src/main/resources/binding.xjb
>> * https://svn.java.net/svn/jaxb2-commons~svn/basics/trunk/tests/issues/src/main/resources/schema.xsd
>>
>>                <jaxb:bindings node="xsd:element[@name='issueJIIB38']">
>>                        <jaxb:class/>
>>                        <inheritance:implements>java.lang.Cloneable</inheritance:implements>
>>                </jaxb:bindings>
>>
>>        <xs:simpleType name="issueJIIB38Type">
>>                <xs:restriction base="xs:string">
>>                        <xs:enumeration value="a"/>
>>                        <xs:enumeration value="b"/>
>>                        <xs:enumeration value="c"/>
>>                        <xs:enumeration value="d"/>
>>                </xs:restriction>
>>        </xs:simpleType>
>>
>>        <xs:element name="issueJIIB38" type="issueJIIB38Type"/>
>>
>> I'm not sure if it is enough, please file an issue if yo miss something.
>>
>> Bye,
>> /lexi