Package org.opennms.core.utils
Class PropertiesUtils
- java.lang.Object
-
- org.opennms.core.utils.PropertiesUtils
-
public abstract class PropertiesUtils extends java.lang.Object
PropertiesUtils class.
- Version:
- $Id: $
- Author:
- ranger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
PropertiesUtils.SymbolTable
-
Constructor Summary
Constructors Constructor Description PropertiesUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
getProperty(java.util.Properties props, java.lang.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 int
getProperty(java.util.Properties props, java.lang.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 long
getProperty(java.util.Properties props, java.lang.String name, long defaultVal)
Get a long valued property, returning default value if it is not set or is set to an invalid valuestatic java.lang.String
getProperty(java.util.Properties props, java.lang.String name, java.lang.String defaultVal)
Get a String valued property, returning default value if it is not set or is set to an invalid value.static java.lang.String
substitute(java.lang.String initialString, java.util.Map<java.lang.String,java.lang.Object>... mapArray)
This recursively substitutes occurrences ${property.name} in initialString with the value of the property property.name taken from the suppliedMap
object.static java.lang.String
substitute(java.lang.String initialString, java.util.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 java.lang.String
substitute(java.lang.String initialString, java.util.Properties properties, java.lang.String prefix, java.lang.String suffix)
substitutestatic java.lang.String
substitute(java.lang.String initialString, PropertiesUtils.SymbolTable... symbolsArray)
substitute
-
-
-
Method Detail
-
substitute
public static java.lang.String substitute(java.lang.String initialString, java.util.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
- aProperties
object.- Returns:
- The string with appropriate substitutions made.
-
substitute
@SafeVarargs public static java.lang.String substitute(java.lang.String initialString, java.util.Map<java.lang.String,java.lang.Object>... mapArray)
This recursively substitutes occurrences ${property.name} in initialString with the value of the property property.name taken from the suppliedMap
object. If property.name is not defined in the map then the substitution is not done.- Parameters:
initialString
- the string to perform the substitutions inmapArray
- aMap
object.- Returns:
- The string with appropriate substitutions made.
-
substitute
public static java.lang.String substitute(java.lang.String initialString, java.util.Properties properties, java.lang.String prefix, java.lang.String suffix)
substitute
- Parameters:
initialString
- aString
object.properties
- aProperties
object.prefix
- aString
object.suffix
- aString
object.- Returns:
- a
String
object.
-
substitute
public static java.lang.String substitute(java.lang.String initialString, PropertiesUtils.SymbolTable... symbolsArray)
substitute
- Parameters:
initialString
- aString
object.symbolsArray
- aPropertiesUtils.SymbolTable
object.- Returns:
- a
String
object.
-
getProperty
public static java.lang.String getProperty(java.util.Properties props, java.lang.String name, java.lang.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
- aProperties
object.- Returns:
- the value of the property
-
getProperty
public static boolean getProperty(java.util.Properties props, java.lang.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
- aProperties
object.- Returns:
- the value of the property
-
getProperty
public static int getProperty(java.util.Properties props, java.lang.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
- aProperties
object.- Returns:
- the value of the property
-
getProperty
public static long getProperty(java.util.Properties props, java.lang.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
- aProperties
object.- Returns:
- the value of the property
-
-