net.sf.jabb.util.prop
Class PlaceHolderReplacer
java.lang.Object
net.sf.jabb.util.prop.PlaceHolderReplacer
public class PlaceHolderReplacer
- extends Object
It can replace the place holders in string with system or user-defined properties.
Its implementation depends on jboss-common-core.jar which is part of JBoss runtime.
- Author:
- James Hu
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PlaceHolderReplacer
public PlaceHolderReplacer()
replaceWithProperties
public static String replaceWithProperties(String str)
- If running inside JBoss, it replace any occurrence of ${p} with the System.getProperty(p) value.
If there is no such property p defined, then the ${p} reference will remain unchanged.
If the property reference is of the form ${p:v} and there is no such property p, then
the default value v will be returned. If the property reference is of the form ${p1,p2}
or ${p1,p2:v} then the primary and the secondary properties will be tried in turn, before
returning either the unchanged input, or the default value. The property ${/} is replaced
with System.getProperty("file.separator") value and the property ${:} is replaced with
System.getProperty("path.separator").
- Parameters:
str - the input string that substitution will be performed upon.
- Returns:
replaceWithProperties
public static String replaceWithProperties(String str,
Properties props)
- If running inside JBoss, it replace any occurrence of ${p} with the System.getProperty(p) value.
If there is no such property p defined, then the ${p} reference will remain unchanged.
If the property reference is of the form ${p:v} and there is no such property p, then
the default value v will be returned. If the property reference is of the form ${p1,p2}
or ${p1,p2:v} then the primary and the secondary properties will be tried in turn, before
returning either the unchanged input, or the default value. The property ${/} is replaced
with System.getProperty("file.separator") value and the property ${:} is replaced with
System.getProperty("path.separator").
- Parameters:
str - the input string that substitution will be performed upon.props - the properties to be used instead of System.getProerty()
- Returns:
Copyright © 2012. All Rights Reserved.