Package com.zfabrik.util
Class PropertyExpressionResolver
java.lang.Object
com.zfabrik.util.PropertyExpressionResolver
The
PropertyExpressionResolver
class provides the functionality to resolve expressions in properties.
An expression is any character sequence enclosed with ${ and }; all characters including space, umlauts, punctuation chars but except '}'
are allowed.
Expressions are resolved by replacing all ${key} sequences by the result of calling getProperty(key) on the input-properties object.
One can escape the an expression by $${ which will be replaced by ${.
The PropertyExpressionResolver
is created using either one Properties
object or two.
In the first case the method resolveAll()
resolves all property-expressions and stores the result in the same object and replaces the original expressions.
In the second case the first Properties
object hosts the expressions and is unchanged while the results are stored in the second Properties
object.-
Constructor Summary
ConstructorDescriptionPropertyExpressionResolver(Properties p_in_out)
Constructs a newPropertyExpressionResolver
object for the givenProperties
.PropertyExpressionResolver(Properties p_in, Properties p_out)
Constructs a newPropertyExpressionResolver
object for the givenProperties p_in
. -
Method Summary
Modifier and TypeMethodDescriptionResolves all property-expressions provided by the input-properties object and stores the result into the output-properties.resolveExpr(String p_expr)
Resolves the given expression string using the input-properties objectresolveKey(String key)
Looks up the given key in the input-properties object and resolves the value using the input-properties object
-
Constructor Details
-
PropertyExpressionResolver
Constructs a newPropertyExpressionResolver
object for the givenProperties p_in
. CallingresolveAll()
will store all resolved property expressions inp_out
.- Parameters:
p_in
- input-properties:Properties
object containing the expressionsp_out
- output-properties:Properties
object which will contain the resolved expressions
-
PropertyExpressionResolver
Constructs a newPropertyExpressionResolver
object for the givenProperties
. CallingresolveAll()
will replace all properties inp_in_out
by the resolved versions.- Parameters:
p_in_out
-Properties
object containing the expressions which will be replaced by the resolved versions
-
-
Method Details
-
resolveAll
Resolves all property-expressions provided by the input-properties object and stores the result into the output-properties.- Returns:
- the same
Properties
object as provided as output-properties to the constructor.
-
resolveExpr
Resolves the given expression string using the input-properties object- Parameters:
p_expr
- string which may contain expressions- Returns:
- string where all expressions are resolved
-
resolveKey
Looks up the given key in the input-properties object and resolves the value using the input-properties object- Parameters:
key
- property key in the input-properties object- Returns:
- string where all expressions are resolved
-