Package org.opennms.core.utils
Class PropertiesUtils
- java.lang.Object
-
- org.opennms.core.utils.PropertiesUtils
-
public abstract class PropertiesUtils extends Object
PropertiesUtils class.
- Version:
- $Id: $
- Author:
- ranger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePropertiesUtils.SymbolTable
-
Constructor Summary
Constructors Constructor Description PropertiesUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleangetProperty(Properties props, String name, boolean defaultVal)Get a boolean valued property, returning default value if it is not set or is set to an invalid value.static intgetProperty(Properties props, String name, int defaultVal)Get a int valued property, returning default value if it is not set or is set to an invalid value.static longgetProperty(Properties props, String name, long defaultVal)Get a long valued property, returning default value if it is not set or is set to an invalid valuestatic StringgetProperty(Properties props, String name, String defaultVal)Get a String valued property, returning default value if it is not set or is set to an invalid value.static Stringsubstitute(String initialString, Map<String,Object>... mapArray)This recursively substitutes occurrences ${property.name} in initialString with the value of the property property.name taken from the suppliedMapobject.static Stringsubstitute(String initialString, Properties... propertiesArray)This recursively substitutes occurrences ${property.name} in initialString with the value of the property property.name taken from the supplied properties object.static Stringsubstitute(String initialString, Properties properties, String prefix, String suffix)substitutestatic Stringsubstitute(String initialString, PropertiesUtils.SymbolTable... symbolsArray)substitute
-
-
-
Method Detail
-
substitute
public static String substitute(String initialString, Properties... propertiesArray)
This recursively substitutes occurrences ${property.name} in initialString with the value of the property property.name taken from the supplied properties object. If property.name is not defined in properties then the substitution is not done.- Parameters:
initialString- the string to perform the substitutions inpropertiesArray- aPropertiesobject.- Returns:
- The string with appropriate substitutions made.
-
substitute
@SafeVarargs public static String substitute(String initialString, Map<String,Object>... mapArray)
This recursively substitutes occurrences ${property.name} in initialString with the value of the property property.name taken from the suppliedMapobject. If property.name is not defined in the map then the substitution is not done.- Parameters:
initialString- the string to perform the substitutions inmapArray- aMapobject.- Returns:
- The string with appropriate substitutions made.
-
substitute
public static String substitute(String initialString, Properties properties, String prefix, String suffix)
substitute
- Parameters:
initialString- aStringobject.properties- aPropertiesobject.prefix- aStringobject.suffix- aStringobject.- Returns:
- a
Stringobject.
-
substitute
public static String substitute(String initialString, PropertiesUtils.SymbolTable... symbolsArray)
substitute
- Parameters:
initialString- aStringobject.symbolsArray- aPropertiesUtils.SymbolTableobject.- Returns:
- a
Stringobject.
-
getProperty
public static String getProperty(Properties props, String name, String defaultVal)
Get a String valued property, returning default value if it is not set or is set to an invalid value.- Parameters:
name- the property namedefaultVal- the default value to use if the property is not setprops- aPropertiesobject.- Returns:
- the value of the property
-
getProperty
public static boolean getProperty(Properties props, String name, boolean defaultVal)
Get a boolean valued property, returning default value if it is not set or is set to an invalid value.- Parameters:
name- the property namedefaultVal- the default value to use if the property is not setprops- aPropertiesobject.- Returns:
- the value of the property
-
getProperty
public static int getProperty(Properties props, String name, int defaultVal)
Get a int valued property, returning default value if it is not set or is set to an invalid value.- Parameters:
name- the property namedefaultVal- the default value to use if the property is not setprops- aPropertiesobject.- Returns:
- the value of the property
-
getProperty
public static long getProperty(Properties props, String name, long defaultVal)
Get a long valued property, returning default value if it is not set or is set to an invalid value- Parameters:
name- the property namedefaultVal- the default value to use if the property is not setprops- aPropertiesobject.- Returns:
- the value of the property
-
-