You want to use Commons BeanUtils to manipulate and access simple, indexed, and nested bean properties.
To use Commons BeanUtils in a Maven 2 project, add the following
dependency to your project's pom.xml
:
Example 3.2. Adding a Dependency on Commons BeanUtils
<dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.8.0</version> </dependency>
If you are not sure what this means, I'd suggest reading Maven: The Definitive
Guide. When you depend on a library in Maven 2, all you need to
do is add the dependency groupId
,
artifactId
, and version
to your
project's dependencies. Once you do this, Maven 2 will download the
dependency and make it available on your project's classpath.
Commons BeanUtils is a collection of utilities that makes working with beans and bean properties much easier. This project contains utilities that allow one to retrieve a bean property by name, sort beans by a property, translate beans to maps, and more. BeanUtils is simple and straightforward, and, as such, you will find that it is one of the most widely used and distributed libraries in open source Java. Along with Commons Lang and Commons Collections, Commons BeanUtils is part of the core of Apache Commons. Unless specified otherwise, every utility mentioned in this chapter is from Commons BeanUtils.
To learn more about Commons BeanUtils, visit the Commons BeanUtils web site: http://commons.apache.org/beanutils/.