de.lessvoid.xml.tools
Class SpecialValuesReplace
java.lang.Object
de.lessvoid.xml.tools.SpecialValuesReplace
public class SpecialValuesReplace
- extends Object
- Author:
- Marc Pompl, void (added some additional features)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SpecialValuesReplace
public SpecialValuesReplace()
replace
public static String replace(String input,
Map<String,ResourceBundle> resourceBundles,
Object methodCallTarget,
Properties properties)
- Tries to replace values surrounded by "${...}". All pieces of the input that are not
part of a "${...}" expression are returned unmodified. Replacement is executed for
all "${...}" values contained in the input. Yes, this means there is support for
multiple "${...}" expressions in input! :)
Example inputs:
${ENV.myEnv}
checks and returns if myEnv
exists in
System.getEnv()
.
${PROP.myProp}
checks and returns if myProp exists in
the given properties. If properties is null
, System.getProperties()
is checked instead.${CALL.myMethod()}
calls the method myMethod()
on the
given object
if it's not null
${resourceBundleId.key}
tries to find the ResourceBundle with the
given id
on the given list of ResourceBundles. And then calls
resourceBundle.get(key)
to translate the value.
- Parameters:
input
- (may be null
)resourceBundles
- Map of pre loaded ResourceBundles with a String idmethodCallTarget
- if the input contains ${CALL...} the target object to call the method withproperties
- if the input contains ${PROP...} the properties to use (may be null
in this case System.getProperties() are used)
- Returns:
- the parsed input
Copyright © 2011. All Rights Reserved.