commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: Betwixt
Date Thu, 18 Apr 2002 07:12:53 GMT
From: "Glen Stampoultzis" <gstamp@iprimus.com.au>
> 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.

e.g.

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...

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

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

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message