wicket.util.lang
Class PropertyResolver

java.lang.Object
  extended by wicket.util.lang.PropertyResolver

public final class PropertyResolver
extends java.lang.Object

This class parses expressions to lookup or set a value on the object that is given.
The supported expressions are:

"property": This can can then be a bean property with get and set method. Or if a map is given as an object it will be lookup with the property as a key when there is not get method for that property.

"property1.property2": Both properties are lookup as written above. If property1 evaluates to null then if there is a setMethod (or if it is a map) and the Class of the property has a default constructor then the object will be constructed and set on the object.

"property.index": If the property is a List or Array then the second property can be a index on that list like: 'mylist.0' this expression will also map on a getProperty(index) or setProperty(index,value) methods. If the object is a List then the list will grow automaticaly if the index is greater then the size

Index or map properties can also be written as: "property[index]" or "property[key]"

Author:
jcompagner

Method Summary
static java.lang.Object getValue(java.lang.String expression, java.lang.Object object)
          Looksup the value from the object with the given expression.
static void setValue(java.lang.String expression, java.lang.Object object, java.lang.Object value, IConverter converter)
          Set the value on the object with the given expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getValue

public static final java.lang.Object getValue(java.lang.String expression,
                                              java.lang.Object object)
Looksup the value from the object with the given expression. If the expresion, the object itself or one property evalutes to null then a null will be returned.

Parameters:
expression - The expression string with the property to be lookup.
object - The object which is evaluated.
Returns:
The value that is evaluted. Null something in the expression evaluted to null.

setValue

public static final void setValue(java.lang.String expression,
                                  java.lang.Object object,
                                  java.lang.Object value,
                                  IConverter converter)
Set the value on the object with the given expression. If the expression can't be evaluated then a WicketRuntimeException will be thrown. If a null object is encounted then it will try to generate it by calling the default constructor and set it on the object. The value will be tried to convert to the right type with the given converter.

Parameters:
expression - The expression string with the property to be set.
object - The object which is evaluated to set the value on.
value - The value to set.
converter - The convertor to convert the value if needed to the right type.


Copyright © 2004-2007 Wicket developers. All Rights Reserved.