You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Glen Stampoultzis <gs...@iprimus.com.au> on 2002/04/18 07:48:59 UTC

Betwixt

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?

Regards,

Glen Stampoultzis  (TriNexus Pty Ltd)
+63 3 9753-6850     0402 835 458
ICQ:  62722370    EMail:  glens@apache.org



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Betwixt

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Glen Stampoultzis" <gs...@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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>