![[DE]](http://www.grayman.de/img/flag-de-mini.gif)
Eine kleine Erweiterung von
Jakarta Commons BeanUtils
die es ermöglicht Eigenschaften eines Bean als Indizes und/oder Schlüssel in einem
indizierten und/oder gemappten Propety-Name usw. zu benutzen.
![[UK]](http://www.grayman.de/img/flag-uk-mini.gif)
Small extension to
Jakarta Commons BeanUtils
which enables the usage of bean's properties as indexes and/or keys in indexed and/or
mapped property names.
Download (Freeware - Apache Software License, Version 2.0)
de.grayman.commons.beanutils
Class InterpolatedPropertyUtilsjava.lang.Object +--de.grayman.commons.beanutils.InterpolatedPropertyUtils
- public class InterpolatedPropertyUtils
- extends java.lang.Object
Similar to PropertyUtils but allows interpolated properties.
The name of a property can contain subexpression eclosed in braces
{ }. These subexpressions will be evaluated before the value of thePropertyUtils.getProperty(java.lang.Object, java.lang.String)evaluated.Example:
When abeanhas the propertyindexwith the value42and an indexed propertyvalues, then the expressionvalues[{index}]is equivalent tovalues[42].The subexpressions itself can be a nested, indexed, mapped or interpolated property. So the following is a valid expression:
a.map({c.values[{d.index}]}).The subexpression does not have to be used as an index or a key, it can also be used as a property name or part thereof:
a.{propName}orxy{propName}are valid expressions, as long as the resulting string is a valid expression.Note: The subexpressions can be nested, but the values of the subexpressions will NOT be recurively interpolated. So, when the property
nameis"{name}"the evaluation of the expression{name}will not cause aStackOverflowErrorbut return"{name}"instead.
Thanks to Günther H. Zylinski for help and feedback.