org.apache.wicket.util.string.interpolator
Class PropertyVariableInterpolator

java.lang.Object
  extended by org.apache.wicket.util.string.interpolator.VariableInterpolator
      extended by org.apache.wicket.util.string.interpolator.PropertyVariableInterpolator
All Implemented Interfaces:
java.io.Serializable, IClusterable, IConverterLocator

public final class PropertyVariableInterpolator
extends VariableInterpolator
implements IConverterLocator

Interpolates values into Strings that are produced by interpreting property expressions against a beans model.

The interpolate(String string, Object model) method takes a string such as " My name is ${name}" and a beans model such as a Person, and reflects on the object using any property expressions found inside ${} markers in the String. In this case, if the Person model has a getName() method. The results of calling that method would be substituted for ${name}. If getName() returned "Jonathan", then interpolate() would return "My name is Jonathan".

"$" is the escape char. Thus "$${text}" can be used to escape it (ignore interpretation).

Since:
1.2.6
Author:
Jonathan Locke
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.wicket.util.string.interpolator.VariableInterpolator
string
 
Method Summary
<C> IConverter<C>
getConverter(java.lang.Class<C> type)
          Returns the Converter for the class that is given.
protected  java.lang.String getValue(java.lang.String variableName)
          Retrieves a value for a variable name during interpolation.
static java.lang.String interpolate(java.lang.String string, java.lang.Object object)
          Interpolates the given String, substituting values for property expressions.
 
Methods inherited from class org.apache.wicket.util.string.interpolator.VariableInterpolator
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

interpolate

public static java.lang.String interpolate(java.lang.String string,
                                           java.lang.Object object)
Interpolates the given String, substituting values for property expressions.

Parameters:
string - a String containing property expressions like ${xyz}
object - the Object to reflect on
Returns:
the interpolated String

getValue

protected java.lang.String getValue(java.lang.String variableName)
Retrieves a value for a variable name during interpolation.

Specified by:
getValue in class VariableInterpolator
Parameters:
variableName - the variable name
Returns:
the value

getConverter

public <C> IConverter<C> getConverter(java.lang.Class<C> type)
Returns the Converter for the class that is given.

Specified by:
getConverter in interface IConverterLocator
Type Parameters:
C - The object to convert from and to String
Returns:
The converter for the given type.


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.