commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: [BeanUtils] PropertyUtils and DynaBeans (getPropertyDescriptors)
Date Wed, 17 Apr 2002 22:03:45 GMT
----- Original Message -----
From: "Stephen Colebourne" <>
> From: Craig R. McClanahan <
> > > There
> > > doesn't seem to be any way to use the one.two[0].three(four) type
> > > however. Maybe this could be added.
> > >
> >
> > It's already there, but not in the DynaBeans themselves ... :-)
> This is what I was getting at. If DynaBeans were to become used as the
> interface (instead of PropertyUtils), then DynaBeans would need to support
> this notation.

I think DynaBeans is a great abstraction for DynaBeans and regular beans.
DynaBeans can handle

* regular properties via get(String name)
* indexed properties via get(String name, int index);
* mapped properties via get(String name, String key);

Where DynaBeans are maybe not the best abstraction right now is for complex
expressions like one.two[3].four(5).

I guess we could always change the get(String) and set(String, Object value)
methods of DynaBean that if the name doesn't match a well defined property
to call the PropertyUtils method to evaluate the expression? I'm not sure
I'm convinced this is a good idea yet but its certainly possible.

Though maybe for complex expressions we should use either the existing
PropertyUtils API for this or some expression API explicitly. Stuff like
these complex expressions might deserve a different API, maybe that allows
expressions to be 'compiled' first then reused many times to avoid excessive
parsing of the exception.


Expression expression = new Expression( "one.two[3].four(5)" );
for ( int i = 0; i < 20; i++ ) {
    expression.evaluate( array[i] );

> This could be done either by adding to the DynaBean interface:
> getNested(String)
> setNested(String, Object)
> or by changing the javadoc and implementation of get(String) and
> Object)
> Any views on the better approach?

Its tempting. It would be nice to have a consistent, simple, clean API like
DynaBeans to handle all these cases.

Though I'd be happy to use DynaBeans for all 'simple' cases, bean
properties, indexed & mapped properties and DynaBeans, then use another API
for 'complex' expressions.

> > The property getter/setter methods in PropertyUtils and BeanUtils work
> > either standard JavaBeans or on DynaBeans, so you can use the exact same
> > property syntax on them.
> Thus implementation should be easy ;-)



Do You Yahoo!?
Get your free address at

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

View raw message