You will be redirected to our new website in 5 seconds...
If you are not automatically taken to our new web site,
please click on the hyperlink :
http://jodd.org
Jodd
build: 309
updated: Jun 17 2008
 

SourceForge.net Logo

freebsd  Support this project

home Home | download | home Contact | SourceForge | File Releases releases | News news |  
Bean
*You can tell a lot about a fellow's character by his way of eating jellybeans. (Ronald Reagan)
Sorry, documentation is not yet complete and does not provide sufficient information. Please refer to test cases, javadoc and sources for more details.
If you need more info on this particular subject, do not hesitate to demand more documentation.

bean Bean utilities allow setting and reading bean properties, as most other similar libraries. However, we think that several things make it different. First, it is the fastest bean manipulation utility. Second, it works with attributes and properties in the same time: when class doesn't define setters and getters, its attributes will be used. Third, there is a nice variety of available functions that might suit most needs. Code is divided in logical sections, so it is easy to use it in specific way, if there is such requirements.

Highlights
  • Feature rich
  • Class fields as bean properties
  • In production since 2005
  • Fast! Fast! Fast!
  • Aware of Map, Lists, Java5 generics

Usage

BeanUtil works with simple, indexed and nested properties, as well as with their combinations. It is aware of arrays, lists and maps.

BeanUtil.getProperty(dest, "fooFloat");
BeanUtil.getDeclaredProperty(cbean, "list[0].map[foo].fooProp"); // reads non-public properties
BeanUtil.setProperty(cbean, "foo", aFooValue);

Setting properties can be done in several ways. By default, setting non-existing property will throw an unchecked exception. Silent setting doesn't throw exception, but returns boolean result about the success of the operation.

Interesting is forced setting. When this type is used, then all null simple properties that are part of some nested property will be created and initialized, even if they are type of array, list or map. For example:

BeanUtil.setPropertyForced(x, "y.foo", value);
BeanUtil.setPropertyForced(x, "yy[2].foo", "xxx");

If object x has uninitialized property y, BeanUtil will create a new instance of y's type, that will be set to y property. After that, foo property of y will be set. In the second case, yy is an array. If it is uninitialized, BeanUtil will create a new array of length 3. Then, it will create new instance of y's type that will be stored as third arrays element. At the end, foo property is set as usual.

Flavors

BeanUtil comes in different flavors: silent (no exception is thrown), forced (creates missing properties), declared (includes non-public properties)...