users@jaxb.java.net

Re: setter or add method for collections

From: Shashi Garje <SGarje_at_cccis.com>
Date: Thu, 15 May 2003 09:03:09 -0500

Brandon
Thanks for the info. It worked.

JAXB Dev group
Is it possible to generate a comment after the getter mentioning why the
setter is not needed etc. just as Brandon has mentioned below. That will
help newbies like me from wasting bandwidth here. Just a thought.





                      Brandon Franklin
                      <brandon_at_thoughtr To: JAXB-INTEREST_at_JAVA.SUN.COM
                      iver.com> cc:
                      Sent by: Subject: Re: setter or add method for collections
                      Discussion list
                      for the Java
                      Architecture for
                      XML Binding
                      <JAXB-INTEREST_at_JA
                      VA.SUN.COM>


                      05/13/2003 07:49
                      PM
                      Please respond to
                      Discussion list
                      for the Java
                      Architecture for
                      XML Binding






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
>