commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rune Johannesen <rune.johanne...@digitalrum.com>
Subject [BeanUtils] - Extensions for dotted queries in composite data str uctures
Date Tue, 18 Mar 2003 18:06:16 GMT
Guys,

Attached you find some classes that extends the functionality of the
existing BeanUtils package;

	ObjectUtils

and

	NestedObjectUtils

The purpose of this extension is to allow bean property queries not only on
pure beans, but in composite data structures that might involve maps, lists,
arrays and collections in addition to the traditional beans.

The ObjectUtils lets you resolve dotted queries like this;

	String text = (String) ObjectUtils.get(namespace,
"session.products.0.children.2.displayText");

as opposed to

	String text = (String) ((List) ((Catalog)
namespace.get("session")).getProducts()).get(0)............

The NestedObjectUtils lets you do the same, but allows nested queries like;

	
"session.products.0.children.{request.parameter.childNumber}.displayText"

The NestedObjectUtils depends on the Commons-Lang
(org.apache.commons.lang.StringUtils) in addition to the existing BeanUtils
dependencies.

I've javadoc'ed the code and provided some unit tests... Let me know what
you think - should this be included in the BeanUtils package in some future
release? What about extending it to support the DynaBean concept? What about
extending the query language in the BeanUtils package in general to support
both traditional () and [] delimiters in addition to the uniformed dot - as
it is used in these classes?


 <<beanutils-extension.zip>> 


Cheers,

Rune

Mime
View raw message