commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: Betwixt
Date Thu, 18 Apr 2002 07:12:53 GMT
From: "Glen Stampoultzis" <>
> Can betwixt be used to read collections of arbitary objects?  For example,
> if I have an ArrayList containing objects of ClassA and ClassB is there
> anyway I can configure things so that they are read in correctly?

Sure. Though the trick is for the bean that owns the ArrayList to have
typesafe 'add' methods.


public class Foo {
    private List list = new ArrayList();

    public void addA(A a) {
        list.add( a );

    public void addB(B b) {
        list.add( b );

    public List getList() {
        return list;

Then your XML could look like...

    <a> ... </a>
    <b> ... </b>

If you don't want to wrap the List in a bean as shown above then using
Digester directly is your best bet.


Do You Yahoo!?
Get your free address at

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message