You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Andrew Hughes <ah...@gmail.com> on 2009/02/13 00:51:24 UTC

commons-beanutils : DynaBean's & List

Howdy,
DynaBean's look brilliant, but I am overwhealmed with options - can anyone
help me out please?

I have a hierarchy of POJO "Thing"'s which is easiest explained.

+ Thing(key="root")
    + Thing(key="world")
        + Thing(key="transport")
            + Thing(key="car")
            + Thing(key="train")
        + Thing(key="feature")
            + Thing(key="road") //note that key'd duplicates exist!
            + Thing(key="road") //note that key'd duplicates exist!
            + Thing(key="tree") //note that key'd duplicates exist!
            + Thing(key="tree") //note that key'd duplicates exist!


Many examples use Map's (but that doesn't allow duplicate key's).

For what it's worth, I would like the following pseudo to work...

get("root.world.feature");



Help would be great,  :)


p.s. the actual key's are out of my control and change dynamically at
runtime.

Re: commons-beanutils : DynaBean's & List

Posted by Andrew Hughes <ah...@gmail.com>.
Ok, I can add one (or more) DynaBean's as a child properties to a parent
DynaBean.

LazyDynaBean x = new LazyDynaBean();//transparent root.
LazyDynaBean root = new LazyDynaBean();
x.set("root",0,root);
LazyDynaBean world = new LazyDynaBean();
root.set("world",0,world);
/////////and so on......

and for duplicates...

x.set("root",0,rootX);
x.set("root",1,rootY);
x.set("root",2,rootZ);

My only suggestion for the commons group would be to have a method..
append(String key, Object value) ; that would not overwrite a corresponding
key's value, but append it to the end of the list. That way I would not have
to do the 0,1,2 above. Mind you I can implement this myself easily enuff -
but just a thought.

Cheers.


On Fri, Feb 13, 2009 at 10:21 AM, Andrew Hughes <ah...@gmail.com> wrote:

> Howdy,
> DynaBean's look brilliant, but I am overwhealmed with options - can anyone
> help me out please?
>
> I have a hierarchy of POJO "Thing"'s which is easiest explained.
>
> + Thing(key="root")
>     + Thing(key="world")
>         + Thing(key="transport")
>             + Thing(key="car")
>             + Thing(key="train")
>         + Thing(key="feature")
>             + Thing(key="road") //note that key'd duplicates exist!
>             + Thing(key="road") //note that key'd duplicates exist!
>             + Thing(key="tree") //note that key'd duplicates exist!
>             + Thing(key="tree") //note that key'd duplicates exist!
>
>
> Many examples use Map's (but that doesn't allow duplicate key's).
>
> For what it's worth, I would like the following pseudo to work...
>
> get("root.world.feature");
>
>
>
> Help would be great,  :)
>
>
> p.s. the actual key's are out of my control and change dynamically at
> runtime.
>