|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.cafesoft.core.util.PropertyUtils
PropertyUtils provides convenience methods for loading Java Properties from disk.
| Constructor Summary | |
PropertyUtils()
|
|
| Method Summary | |
static boolean |
getBooleanValue(Properties properties,
String propertyName,
boolean defaultValue)
Get a boolean value from a Properties object. |
static int |
getIntegerValue(Properties properties,
String propertyName,
int defaultValue)
Get a integer value from a Properties object. |
static int |
getIntegerValue(Properties properties,
String propertyName,
int defaultValue,
Object source,
Logger logger)
Get a integer value from a Properties object. |
static Properties |
load(File file)
Load Properties from a File. |
static Properties |
load(String filePath)
Load Properties from a file at the specified path. |
static Properties |
parseProperties(String propString,
char pairSep,
char namevalSep)
Parse Properties from a String. |
static Properties |
parseProperties(String propString,
String pairSep,
char namevalSep)
Parse Properties from a String. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public PropertyUtils()
| Method Detail |
public static Properties load(File file)
If an Exception occurs, write a stack trace to the current PrintStream. (The default PrintStream is System.err).
file - the Properties File to be loaded.
public static Properties load(String filePath)
If an Exception occurs, write a stack trace to the current PrintStream. (The default PrintStream is System.err).
filePath - the path to the Properties file to be loaded.
public static Properties parseProperties(String propString,
char pairSep,
char namevalSep)
For example, if propString is: name1=value1,name2=value2
then pairSep = ',' and namevalSep = '='
propString - the String containing properties to be parsed.pairSep - the character used to separate name=value pairs.namevalSep - the character used to separate a name from a value.
public static Properties parseProperties(String propString,
String pairSep,
char namevalSep)
For example, if propString is: name1=value1, name2=value2
and pairSep = ", " and namevalSep = '='
propString - the String containing properties to be parsed.pairSep - a String containing the characters than can separate
name=value pairs. For example: ", \t\n\r" would match a comma, space,
tab, newline, and carriage return characters.namevalSep - the character used to separate a name from a value.
public static boolean getBooleanValue(Properties properties,
String propertyName,
boolean defaultValue)
This method will get the property specified by the propertyName parameter from the given properties object. If the value does not exist the defaultValue parameter will be returned.
properties - the Properties object to get the boolean value from.propertyName - the parameter name to get.defaultValue - the default value to return if the parameter
name does not exist in the Properties object.
public static int getIntegerValue(Properties properties,
String propertyName,
int defaultValue)
This method will get the property specified by the propertyName parameter from the given properties object. If the value does not exist the defaultValue parameter will be returned.
properties - the Properties object to get the int value from.propertyName - the parameter name to get.defaultValue - the default value to return if the parameter
name does not exist in the Properties object.
public static int getIntegerValue(Properties properties,
String propertyName,
int defaultValue,
Object source,
Logger logger)
This method will get the property specified by the propertyName parameter from the given properties object. If the value does not exist the defaultValue parameter will be returned. If the logger is not null a warning message will be logged.
properties - the Properties object to get the int value from.propertyName - the parameter name to get.defaultValue - the default value to return if the parameter
name does not exist in the Properties object.source - the object attempting to get the int value. Used for
logging purposes. If null the PropertyUtils.class value is used.logger - the logger to log the warning message to. If the logger
is null then no error message is logged.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||