Keith,

My confusion was because the public API that was generated did not have anything to do 
with
Java 2 Collections API. Only the private implementation did. As a user of castor it is 
the
public API of the generated code that is relevant to me. To further add to the 
confusion was
that the documentation at:

    http://castor.exolab.org/sourcegen.html#Collection-Types

said the command line option was "types -j2" instead of "-types j2". I was using the 
latter
which is correct but was wondering whether I was using the right options as the 
generated code
did not seem to be exposing Java 2 Collections API.

Thanks again for building a very good toolkit and a robust community around it.

--
Regards,
Farrukh


Keith Visco wrote:

> Farrukh Najmi wrote:
> >
> > I generated Java Source for my schema using SourceGenerator with the
> > "-types j2" command line option. The resulting code indeed used
> > java.util.ArrayList instead java.util.Vector. However, that was a
> > private data memeber. The public API that was generated still uses:
> >
> > -Enumeration instead of Iterator
> >
> >     /**
> >     **/
> >     public java.util.Enumeration enumerateObjectRefListItem()
> >     {
> >         return new
> > org.exolab.castor.util.IteratorEnumeration(_items.iterator());
> >     } //-- java.util.Enumeration enumerateObjectRefListItem()
> >
> > Instead of
> >
> >     public java.util.Iterator iteratorForObjectRefListItem() {
> >         return _items.iterator();
> >     }
>
> This one needs to be fixed in the CVS...
>
> >
> > -Provides a get method that return an Java Array '[]' instead of an
> > ArrayList
>
> This one can be added...but as an option...Even in Java 1.0 collections
> we do not expose the actual collection to the user, but rather hide the
> implementation of the collection by returning only arrays.
>
> Perhaps we can add castorbuilder.properties flag for this.
>
> >
> >     /**
> >     **/
> >     public org.oasis.ebxml.registry.bindings.rim.ObjectRefListItem[]
> > getObjectRefListItem()
> >     {
> >         int size = _items.size();
> >         org.oasis.ebxml.registry.bindings.rim.ObjectRefListItem[] mArray
> > = new org.oasis.ebxml.registry.bindings.rim.ObjectRefListItem[size];
> >         for (int index = 0; index < size; index++) {
> >             mArray[index] = (ObjectRefListItem) _items.get(index);
> >         }
> >         return mArray;
> >     } //-- org.oasis.ebxml.registry.bindings.rim.ObjectRefListItem[]
> > getObjectRefListItem()
> >
> > Instead of:
> >
> >     public ArrayList getObjectRefListItem() {
> >         return (ArrayList)_items.clone();
> >     }
> >
> > I am quite confused by this unexpected behaviour.
>
> Are you really that confused by it? It's simple abstraction. Hiding the
> implementation details from the user. I'm glad that you at least used
> "clone" in your example to prevent the actual array list from being
> modified.
>
> > Am I using Castor XML Source Generator incorrectly or are these issues bugs in the 
>latest
> > version?
>
> One bug, one possible missing feature.
>
> --Keith
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to