org.openbp.common.property
Class PropertyAccessUtil

java.lang.Object
  extended by org.openbp.common.property.PropertyAccessUtil

public final class PropertyAccessUtil
extends java.lang.Object

Utility class that provides methods to access properties of an object dynamically. Wraps Apache Common-PropertyUtils.

Author:
Heiko Erhardt

Method Summary
static java.lang.Object getProperty(java.lang.Object base, java.lang.String property)
          Gets the value of the specified property of an object.
static void setProperty(java.lang.Object base, java.lang.String property, java.lang.Object value)
          Sets the value of the specified property of an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProperty

public static java.lang.Object getProperty(java.lang.Object base,
                                           java.lang.String property)
                                    throws PropertyException
Gets the value of the specified property of an object. This just wraps the Apache Common-PropertyUtils class in convenient exception handling.

Parameters:
base - Object that holds the property
property - Property name; all property access methods supported by PropertyUtils is valid.
Returns:
The value of the property
Throws:
PropertyException - If no appropriate access method could be found or if the invocation of one of the property access methods failed. The nested exception describes the error in detail.

setProperty

public static void setProperty(java.lang.Object base,
                               java.lang.String property,
                               java.lang.Object value)
                        throws PropertyException
Sets the value of the specified property of an object. In order to access the property, the method uses the following strategy. We assume the name of the property is "Sample"
  1. Search for a method named get\iSample\i
  2. Try direct field access on the member \isample\i
  3. Try to use map-style access to properties by calling the method get("Sample")

Parameters:
base - Object to invoke the method on
property - Property name
value - Property value Property chains of the form "prop1.prop2" are *not* supported.
Throws:
PropertyException - If no appropriate access method could be found or if the invocation of one of the property access methods failed.
The nested exception describes the error in detail.


Copyright © 2011. All Rights Reserved.