You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Augusto Rodriguez <au...@dinmax.com> on 2004/09/21 23:12:21 UTC

some setters aren't generated by the ant task

Hi Everyone !

I'm having some problems (i think they are bugs or missing functionalities).
When i generate class files using the ant task the setters of the properties
that return java.util.List are not generated.

for example using this schema

------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="http://lightech.com/test" 
    xmlns="http://lightech.com/test" 
    elementFormDefault="qualified" attributeFormDefault="unqualified" >

    <xs:element name="list">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="items" type="Items"  />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

    <xs:complexType name="Items">
        <xs:sequence>
            <xs:element name="item" type="Item" minOccurs="0"
maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="Item">
        <xs:sequence>
            <xs:element name="item" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>
---------------------------------------------------------


the Items iterface is generated like this..

------------------------------------------------------
package com.lightech.test;

public interface Items {
  public java.util.List getItem();
}
-------------------------------------------------------

i could add the setItem() and addItem() method to the inteface and to
ItemsImpl class but i think it would be faster if jaxme genererates those for
one..



i'm in the right direction? or lost in space??

Thanks!
Augusto

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: some setters aren't generated by the ant task

Posted by Jochen Wiedmann <jo...@freenet.de>.
Augusto Rodriguez wrote:

> I'm having some problems (i think they are bugs or missing functionalities).
> When i generate class files using the ant task the setters of the properties
> that return java.util.List are not generated.

I admit that this is indeed not the style that I prefer. However, it is, 
what the JAXB RI does. And so, we do the same, for compatibility reasons.

The problem is, IMO, not as big as you might think: Rather than writing

     setFoo(list);

you have the possibility to write

     getFoo().addAll(list);

I am personally open for other supporting setters, as a vendor 
extension. This is relatively easy, by creating a subclass of 
MultiplePropertySG and overwriting the methods getXMLSetMethod 
(obviously) and generate (invokes super.generate and a new method
getXMLAddMethod). It is also possible, to modify the MultiplePropertySG.

The important part, for compliance with the JAXB specification, is, that 
the subclass (or the modifications) are being activated only, if

     ((JAXBElement) element).getJAXBProperty().getCollectionType()

in JAXBParticleSG.newPropertySGChain returns some special value. In 
other words, in your XML schema, you would write

     <xs:element name="myElement" maxOccurs="unbounded">
       <xs:annotation><xs:appinfo>
         <jaxb:property collectionType="someSpecialValue"/>
       <xs:appinfo></xs:annotation>
       ...
     </xs:element>

(It would also be possible, to change the default in the globalBindings, 
but that's a simple addition.)

In other words, if you provide a patch in the above sense, I'd be happy 
to accept it. (And while you're at it, why not supply an additional 
class ArrayPropertySG, triggered by the special value "array", that 
creates array valued setters and getters?)


Jochen


-- 
http://lilypie.com/baby1/050423/1/5/1/+1

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org