|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wicket.util.string.interpolator.VariableInterpolator
public abstract class VariableInterpolator
Base class for variable interpolators. An interpolator substitutes values into a
String. So, a variable interpolator substitutes the values of one or more variables
into a String.
The String to interpolate (substitute into) is passed to the
VariableInterpolator's constructor. Variables are denoted in this string by the
syntax ${variableName}. A subclass provides an implementation for the abstract
method getValue(String variableName). The toString() method then
performs an interpolation by replacing each variable of the form ${variableName}
with the value returned by getValue("variableName").
"$" is the escape char. Thus "$${text}" can be used to escape it (ignore interpretation). If '$3.24' is needed then '$$${amount}' should be used. The first $ sign escapes the second, and the third is used to interpolate the variable.
| Field Summary | |
|---|---|
protected String |
string
The String to interpolate into |
| Constructor Summary | |
|---|---|
VariableInterpolator(String string)
Constructor. |
|
VariableInterpolator(String string,
boolean exceptionOnNullVarValue)
Constructor. |
|
| Method Summary | |
|---|---|
protected abstract String |
getValue(String variableName)
Retrieves a value for a variable name during interpolation. |
String |
toString()
Interpolates using variables. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final String string
String to interpolate into
| Constructor Detail |
|---|
public VariableInterpolator(String string)
string - a String to interpolate with variable values
public VariableInterpolator(String string,
boolean exceptionOnNullVarValue)
string - a String to interpolate with variable valuesexceptionOnNullVarValue - if true an IllegalStateException will be thrown if
getValue(String) returns null, otherwise the
${varname} string will be left in the String so that
multiple interpolators can be chained| Method Detail |
|---|
protected abstract String getValue(String variableName)
variableName - a variable name
public String toString()
toString in class ObjectString
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||