org.freehep.application
Class PropertyUtilities
java.lang.Object
org.freehep.application.PropertyUtilities
public abstract class PropertyUtilities
- extends Object
A set of static methods for operating on a Properties set
- Version:
- $Id: PropertyUtilities.java 8584 2006-08-10 23:06:37Z duns $
- Author:
- tonyj
- See Also:
Properties
Method Summary |
static boolean |
getBoolean(Properties prop,
String key,
boolean def)
|
static Color |
getColor(Properties prop,
String key,
Color def)
|
static float |
getFloat(Properties prop,
String key,
float def)
|
static int |
getInteger(Properties prop,
String key)
|
static int |
getInteger(Properties prop,
String key,
int def)
|
static Rectangle |
getRectangle(Properties prop,
String key,
Rectangle def)
|
static String |
getString(Properties prop,
String key,
String def)
|
static String[] |
getStringArray(Properties prop,
String key,
String[] def)
|
static Collection |
getStringCollection(Properties prop,
String key,
Collection def)
|
static URL |
getURL(Properties prop,
String key,
URL def)
Load a URL from a properties file. |
static void |
setBoolean(Properties prop,
String key,
boolean value)
|
static void |
setColor(Properties prop,
String key,
Color c)
|
static void |
setFloat(Properties prop,
String key,
float f)
|
static void |
setInteger(Properties prop,
String key,
int i)
|
static void |
setRectangle(Properties prop,
String key,
Rectangle rect)
|
static void |
setString(Properties prop,
String key,
String s)
|
static void |
setStringArray(Properties prop,
String key,
String[] sa)
|
static void |
setStringCollection(Properties prop,
String key,
Collection sa)
|
static void |
setURL(Properties prop,
String key,
URL url)
|
static String |
translate(Properties prop,
String in)
Translates a string by substituting tokens of the form {name} to the
value of property name in the properties set. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PropertyUtilities
public PropertyUtilities()
getRectangle
public static Rectangle getRectangle(Properties prop,
String key,
Rectangle def)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertydef
- a default in case the property cannot be retrieved
setRectangle
public static void setRectangle(Properties prop,
String key,
Rectangle rect)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertyrect
- the value to store
getColor
public static Color getColor(Properties prop,
String key,
Color def)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertydef
- a default in case the property cannot be retrieved
setColor
public static void setColor(Properties prop,
String key,
Color c)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertyc
- the value to store
getStringCollection
public static Collection getStringCollection(Properties prop,
String key,
Collection def)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertydef
- a default in case the property cannot be retrieved
setStringCollection
public static void setStringCollection(Properties prop,
String key,
Collection sa)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertysa
- the value to store
getStringArray
public static String[] getStringArray(Properties prop,
String key,
String[] def)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertydef
- a default in case the property cannot be retrieved
setStringArray
public static void setStringArray(Properties prop,
String key,
String[] sa)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertysa
- the value to store
getString
public static String getString(Properties prop,
String key,
String def)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertydef
- a default in case the property cannot be retrieved
setString
public static void setString(Properties prop,
String key,
String s)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertys
- the value to store
getBoolean
public static boolean getBoolean(Properties prop,
String key,
boolean def)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertydef
- a default in case the property cannot be retrieved
setBoolean
public static void setBoolean(Properties prop,
String key,
boolean value)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertyvalue
- the value to store
getInteger
public static int getInteger(Properties prop,
String key)
throws NumberFormatException
- Parameters:
prop
- The Properties setkey
- the key used to store this property
- Throws:
NumberFormatException
- if the property retrieved cannot be converted to int
getInteger
public static int getInteger(Properties prop,
String key,
int def)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertydef
- a default in case the property cannot be retrieved
setInteger
public static void setInteger(Properties prop,
String key,
int i)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertyi
- the value to store
setFloat
public static void setFloat(Properties prop,
String key,
float f)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertyf
- the value to store
getFloat
public static float getFloat(Properties prop,
String key,
float def)
- Parameters:
prop
- The Properties setkey
- the key used to store this propertydef
- a default in case the property cannot be retrieved
setURL
public static void setURL(Properties prop,
String key,
URL url)
getURL
public static URL getURL(Properties prop,
String key,
URL def)
- Load a URL from a properties file. If the URL begins with / it is taken to be a
system resource (i.e. on the classpath).
translate
public static String translate(Properties prop,
String in)
- Translates a string by substituting tokens of the form {name} to the
value of property name in the properties set.
- Parameters:
prop
- The properties setin
- The string to be translated
- Returns:
- The resulting string.
Copyright © 2000-2006 FreeHEP. All Rights Reserved.