users@jaxb.java.net

Re: JAXB customization question

From: Ed Mooney <Ed.Mooney_at_sun.com>
Date: Wed, 14 May 2003 10:39:44 -0400

Hi Jerome,

You can do something like this (example taken from spec):

   XML Schema fragment:

   <xs:complexType name="Base">
     <xs:choice maxOccurs="unbounded">
       <xs:annotation>
         <xs:appinfo>
           <jaxb:property name="items" />
         </xs:appinfo>
       </xs:annotation>
       <xs:element name="A" type="xs:string"/>
       <xs:element name="B" type="xs:string"/>
       <xs:element name="C" type="xs:int"/>
     </xs:choice>
   </xs:complexType>

   Customized derived code:

   interface Base {
     interface A extends javax.xml.bind.Element {...}
     interface B extends javax.xml.bind.Element {...}
     interface C extends javax.xml.bind.Element {...}

     /**
     * A general content list that can contain
     * instances of Base.A, Base.B and Base.C.
     */

     // List getAOrBOrC(); - default

     List getItems();// Customized Code
   }

You could try changing the property name to "content," but this may
cause a name collision (not trusting my memory here).

Regards,
--
Ed Mooney         |Sun Microsystems, Inc.|Time flies like
Java Web Services |UBUR02-201            |an arrow, but
Ed.Mooney_at_Sun.COM |1 Network Drive       |fruit flies like
781-442-0459      |Burlington, MA  01803 |a banana. Groucho
Jerome Candat wrote:
> Hello,
>
> I'm new to Jaxb technology.
>
> I was wondering if it is possible to change the name of the methods generated using the JAXB customization process?
>
> In fact, in my XML file, I have an element containing a choice. This choice has 4 different elements called integer, real, record and character. Jaxb generates a method like : getIntegerOrReafOrRecord(). I would like to change the name of this method to getContent().
>
> Thanks in advance,
> Jerome.