I have entered a feature request at  http://jira.codehaus.org/browse/CASTOR

It is http://jira.codehaus.org/browse/CASTOR-3193 "Castor - XML - 
FieldMappingCollectionType - add java.util.Queue as a new collection type"

There are 3 files attached to the jira that help to show the issue.

Cheers
Alan Hawrelak

-----Original Message-----
From: Werner Guttmann [mailto:[email protected]] 
Sent: Friday, September 16, 2011 12:20 PM
To: [email protected]
Cc: Alan Hawrelak
Subject: Re: [castor-user] using Queue as a collection

Hi Alan,

why not create a feature request over at 
http://jira.codehaus.org/browse/CASTOR, and work with us on gettin this 
collection type potentially added.

Kind Regards
Werner Guttmann

On 16.09.2011 17:29, Alan Hawrelak wrote:
> I am trying to use castor 1.3.1, where a collection is a java.util.Queue.
>
> Actually a ConcurrentLinkedQueue<TQueueElement>.
>
> When I try:
>
> Mapping mapping = new Mapping();
>
> mapping.loadMapping("file://castorTestMapping.xml
> <file:///\\castorTestMapping.xml>" );;
>
> It causes the error:
>
> Nested error: org.exolab.castor.xml.MarshalException:
> java.lang.IllegalArgumentException: java.util.Queue is not a valid
> FieldMappingCollectionType
>
> Is there some other collection that will work for this? Or an alternate
> way of doing this?
>
> Thanks.
>
> Here is the a part of the mapping file:
>
> <class name="com.test.TQueue">
>
> <field name="queue_" collection="java.util.Queue"
> type="com.test.TQueueElement" get-method="getQueue" set-method="setQueue">
>
> <bind-xml name="Queue"/>
>
> </field>
>
> <field name="name_" type="java.lang.String" get-method="getName"
> set-method="setName" >
>
> <bind-xml name="QueueName" node="attribute" />
>
> </field>
>
> <field name="type_" type="java.lang.String" get-method="getType"
> set-method="setType" >
>
> <bind-xml name="QueueType" node="attribute" />
>
> </field>
>
> </class>
>
> <class name="com.test.TQueueElement">
>
> <field name="payload_" type="org.exolab.castor.mapping.MapItem"
> collection="map" get-method="getPayload" set-method="setPayload">
>
> <bind-xml name="queueItem">
>
> <class name="org.exolab.castor.mapping.MapItem">
>
> <field name="key" type="java.lang.String">
>
> </field>
>
> <field name="value" type="java.lang.String" />
>
> </class>
>
> </bind-xml>
>
> </field>
>
> </class>
>
> And the related java classes (simplified) are:
>
> public class TQueue
>
> {
>
> private Queue<TQueueElement> queue_;
>
> private String name_;
>
> private String type_;
>
> public TQueue()
>
> {
>
> queue_ = new ConcurrentLinkedQueue<TQueueElement>();
>
> }
>
> public void add(TQueueElement element)
>
> {
>
> if ( element == null ) {
>
> throw new NullPointerException();
>
> }
>
> queue_.add(element);
>
> }
>
> public synchronized String getName()
>
> {
>
> return name_;
>
> }
>
> public synchronized String getType()
>
> {
>
> return type_;
>
> }
>
> public synchronized void setName(String name)
>
> {
>
> if ( name == null ) {
>
> throw new NullPointerException();
>
> }
>
> name_ = name;
>
> }
>
> public synchronized void setType(String type)
>
> {
>
> if ( type == null ) {
>
> throw new NullPointerException();
>
> }
>
> type_ = type;
>
> }
>
> }
>
> public class TQueueElement implements Cloneable {
>
> private Map<String,String> payload_;
>
> public TQueueElement()
>
> {
>
> payload_ = new HashMap<String,String>();
>
> }
>
> public String getEntry(String name) {
>
> return getPayload().get(name);
>
> }
>
> public Map<String,String> getPayload()
>
> {
>
> return payload_;
>
> }
>
> public String putEntry(String name, String value)
>
> {
>
> return getPayload().put(name, value);
>
> }
>
> public void setPayload(Map<String,String> payload)
>
> {
>
> if ( payload == null ) {
>
> throw new NullPointerException();
>
> }
>
> payload_ = payload;
>
> }
>
> }
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to