public class PropertyVariableInterpolator extends VariableInterpolator
String
s that are produced by interpreting property
expressions against an object.
Takes a string such as "My name is ${name}
" and a bean 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 the result
would return "My name is Jonathan"
.
"$" 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.
string
Constructor and Description |
---|
PropertyVariableInterpolator(String string,
Object object)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected String |
getValue(String variableName)
Retrieves a value for a variable name during interpolation.
|
protected String |
toString(Object value)
Convert the given value to a string for interpolation.
|
toString
protected String getValue(String variableName)
VariableInterpolator
getValue
in class VariableInterpolator
variableName
- a variable nameprotected String toString(Object value)
This default implementation delegates to Strings.toString(Object)
.
value
- the value, never null
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.