users@jaxb.java.net

Re: setter or add method for collections

From: Brandon Franklin <brandon_at_thoughtriver.com>
Date: Wed, 14 May 2003 10:19:17 +0930

Hi Shashi. You don't actually need a setter or getter method on the JAXB
generated class, because List has it for you. All you need to do is get the
List and then interact with it in the usual way. Remember that the List is
a reference, not a copy, so the changes will be present inside the JAXB
object.

-Brandon
 Thought River South

----- Original Message -----
From: "Shashi Garje" <SGarje_at_cccis.com>
To: <JAXB-INTEREST_at_JAVA.SUN.COM>
Sent: Wednesday, May 14, 2003 4:53 AM
Subject: setter or add method for collections


> Hi
> This looks like a basic topic that must have been discussed a year ago but
> I was not able to find anything in the archive.
>
> I have the equivalent of a hashmap which I represent using the xsd
>
> <xsd:complexType name="HashMap">
> <xsd:sequence>
> <xsd:element name="entry" type="internal:Entry"
minOccurs
> ="0" maxOccurs="unbounded" />
> </xsd:sequence>
>
> </xsd:complexType>
> <xsd:complexType name="Entry">
> <xsd:sequence>
> <xsd:element name="key" type="xsd:string"/>
> <xsd:element name="value" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType>
>
> When I generated the Java classes using JAXB it generated only a getter
for
> the List of Entry objects
> java.util.List getEntry();
> It did not generate a setter or an add method. I would like to generate
the
> object programmatically and then marshal it to XML.
> Please let me know how that can be done.
> Thanks
>