users@jaxb.java.net

RE: CollectionType java.util.Set

From: Lichtenwalter, Ryan <ryan.lichtenwalter_at_lmco.com>
Date: Mon, 13 Nov 2006 10:53:16 -0600

If you look in the JAXB documentation, collectionType has to implement
the java.util.List interface. java.util.Set does not. It would be
relatively easy to write a class that extends ArrayList or otherwise
implements List that prevents duplicate entries. I am not sure how this
class could be hooked up to JAXB though.

It seems, however, like this would be something you would want to handle
in whatever code is actually supplying the list objects, not in the
process of marshalling and unmarshalling. At that point, you can't
really handle it as well.

Ryan

-----Original Message-----
From: Scott Allan [mailto:sallan1000_at_aol.com]
Sent: Monday, November 13, 2006 10:24 AM
To: users_at_jaxb.dev.java.net
Subject: CollectionType java.util.Set

Can collectionType="java.util.Set" be used? I tried setting it and got
this as a result which will not compile. I'm trying to find a way to
prevent duplicates.

     protected List<PersonRecord> personRecord = new Set<PersonRecord>
();

     /**
      * Gets the value of the personRecord property.
      *
      * <p>
      * This accessor method returns a reference to the live list,
      * not a snapshot. Therefore any modification you make to the
      * returned list will be present inside the JAXB object.
      * This is why there is not a <CODE>set</CODE> method for the
personRecord property.
      *
      * <p>
      * For example, to add a new item, do as follows:
      * <pre>
      * getPersonRecord().add(newItem);
      * </pre>
      *
      *
      * <p>
      * Objects of the following type(s) are allowed in the list
      * {_at_link PersonRecord }
      *
      *
      */
     public List<PersonRecord> getPersonRecord() {
         if (personRecord == null) {
             personRecord = new Set<PersonRecord>();
         }
         return this.personRecord;
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net