users@jaxb.java.net

Re: Only getXXX() is generated for list

From: joe user <palehaole_at_yahoo.com>
Date: Wed, 23 Apr 2003 17:40:26 -0700

--- Boming Zeng <boming_at_SAVVION.COM> wrote:
> Hello,
>
> I have a simple schema which defines an element
> "MyTest"
> containing a sub-element "param", whose "maxOccurs"
> attribute is "unbounded". In the generated class -
> MyTestType.java, only getParam() is supplied, not
> the
> corresponding setParam(List). Without setXXX(), how
> could we set the value for this element?

I think what is happening is that if you use
"unbounded" and you get a list, instead of doing
setFoo(someList), you use List l = x.getFoo() and then
l.add(anotherThing).

This wasn't obvious to me the first time I looked at
it. I try to make most or all of my Java classes
immutable so that idea of intentionally modifying a
list so that it will have an effect on another object
was not intuitive to me. This is one place where some
kind of generic types capabilities in Java would make
JAXB a lot easier to use. Hopefully Java 1.5 will
have that.


__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com