commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Holger Haag" <j...@herr-der-mails.de>
Subject [betwixt] Betwixt mapping of generic lists with instances of an interface
Date Thu, 11 May 2006 12:22:29 GMT
Hi all,

I'm trying to figure out how (or if) it is possible to handle lists
containing instances of an interface.

Sample:

// the interface
public interface MyInterface {
  ..
}

// an implementation
public class MyImpl1 implements MyInterface {
  ..
}

// an implementation
public class MyImpl2 implements MyInterface {
  ..
}

// the list containing instances of MyInterface
public class MyList extends java.util.List<MyInterface> {
  ..
}


A serialized sample should look like the following

<list>
  <!-- serialized instance of MyImpl1 -->
  <impl1>
  </impl1>
  
  <!-- serialized instance of MyImpl2 -->
  <impl2>
  </impl2>
  
  <!-- serialized instance of MyImpl1 -->
  <impl1>
  </impl1>
</list>


I think this is currently not possible via betwixt (pls. correct me if I am
wrong) 
since all list items will be named "myinterface" or so thus loosing the
proper type information.


I could of course build an XML as follows:

<list>
  <item type="myimpl1">
  </item>
  <item type="myimpl2">
  </item>
  <item type="myimpl1">
  </item>
</list>


But this way I have difficulties in defining a nice XSD file for the
generated XML. 
So I'd rather name the nodes properly as outlined in the first XML sample.

So the question boils down to how to setup polymorphic mapping for generic
lists. 
http://jakarta.apache.org/commons/betwixt/guide/reading.html only details
how to do this for a container, but nothing about lists/collections.


Any help is greatly appreciated

-- 
Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message