org.opennms.core.utils
Class PropertiesUtils

java.lang.Object
  extended by org.opennms.core.utils.PropertiesUtils

public abstract class PropertiesUtils
extends Object

PropertiesUtils class.

Version:
$Id: $
Author:
ranger

Nested Class Summary
static interface PropertiesUtils.SymbolTable
           
 
Constructor Summary
PropertiesUtils()
           
 
Method Summary
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.
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.
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
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.
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.
static String substitute(String initialString, Properties properties, String prefix, String suffix)
          substitute
static String substitute(String initialString, PropertiesUtils.SymbolTable... symbolsArray)
          substitute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesUtils

public PropertiesUtils()
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 that the substitution is not done.

Parameters:
initialString - the string to perform the substitutions in
propertiesArray - a Properties object.
Returns:
The string with appropriate substitutions made.

substitute

public static String substitute(String initialString,
                                Properties properties,
                                String prefix,
                                String suffix)

substitute

Parameters:
initialString - a String object.
properties - a Properties object.
prefix - a String object.
suffix - a String object.
Returns:
a String object.

substitute

public static String substitute(String initialString,
                                PropertiesUtils.SymbolTable... symbolsArray)

substitute

Parameters:
initialString - a String object.
symbolsArray - a PropertiesUtils.SymbolTable object.
Returns:
a String object.

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 name
defaultVal - the default value to use if the property is not set
props - a Properties object.
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 name
defaultVal - the default value to use if the property is not set
props - a Properties object.
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 name
defaultVal - the default value to use if the property is not set
props - a Properties object.
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 name
defaultVal - the default value to use if the property is not set
props - a Properties object.
Returns:
the value of the property


Copyright © 2011. All Rights Reserved.