org.freehep.application
Class PropertyUtilities

java.lang.Object
  extended by 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

Nested Class Summary
static class PropertyUtilities.PropertyTable
          Creates a TableModel from a property set
static class PropertyUtilities.TranslatedProperties
          A Properties object whose values and defaults are automatically translated if they contain {prop} tokens.
 
Constructor Summary
PropertyUtilities()
           
 
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
 

Constructor Detail

PropertyUtilities

public PropertyUtilities()
Method Detail

getRectangle

public static Rectangle getRectangle(Properties prop,
                                     String key,
                                     Rectangle def)
Parameters:
prop - The Properties set
key - the key used to store this property
def - a default in case the property cannot be retrieved

setRectangle

public static void setRectangle(Properties prop,
                                String key,
                                Rectangle rect)
Parameters:
prop - The Properties set
key - the key used to store this property
rect - the value to store

getColor

public static Color getColor(Properties prop,
                             String key,
                             Color def)
Parameters:
prop - The Properties set
key - the key used to store this property
def - a default in case the property cannot be retrieved

setColor

public static void setColor(Properties prop,
                            String key,
                            Color c)
Parameters:
prop - The Properties set
key - the key used to store this property
c - the value to store

getStringCollection

public static Collection getStringCollection(Properties prop,
                                             String key,
                                             Collection def)
Parameters:
prop - The Properties set
key - the key used to store this property
def - a default in case the property cannot be retrieved

setStringCollection

public static void setStringCollection(Properties prop,
                                       String key,
                                       Collection sa)
Parameters:
prop - The Properties set
key - the key used to store this property
sa - the value to store

getStringArray

public static String[] getStringArray(Properties prop,
                                      String key,
                                      String[] def)
Parameters:
prop - The Properties set
key - the key used to store this property
def - a default in case the property cannot be retrieved

setStringArray

public static void setStringArray(Properties prop,
                                  String key,
                                  String[] sa)
Parameters:
prop - The Properties set
key - the key used to store this property
sa - the value to store

getString

public static String getString(Properties prop,
                               String key,
                               String def)
Parameters:
prop - The Properties set
key - the key used to store this property
def - a default in case the property cannot be retrieved

setString

public static void setString(Properties prop,
                             String key,
                             String s)
Parameters:
prop - The Properties set
key - the key used to store this property
s - the value to store

getBoolean

public static boolean getBoolean(Properties prop,
                                 String key,
                                 boolean def)
Parameters:
prop - The Properties set
key - the key used to store this property
def - a default in case the property cannot be retrieved

setBoolean

public static void setBoolean(Properties prop,
                              String key,
                              boolean value)
Parameters:
prop - The Properties set
key - the key used to store this property
value - the value to store

getInteger

public static int getInteger(Properties prop,
                             String key)
                      throws NumberFormatException
Parameters:
prop - The Properties set
key - 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 set
key - the key used to store this property
def - a default in case the property cannot be retrieved

setInteger

public static void setInteger(Properties prop,
                              String key,
                              int i)
Parameters:
prop - The Properties set
key - the key used to store this property
i - the value to store

setFloat

public static void setFloat(Properties prop,
                            String key,
                            float f)
Parameters:
prop - The Properties set
key - the key used to store this property
f - the value to store

getFloat

public static float getFloat(Properties prop,
                             String key,
                             float def)
Parameters:
prop - The Properties set
key - the key used to store this property
def - 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 set
in - The string to be translated
Returns:
The resulting string.


Copyright © 2000-2006 FreeHEP. All Rights Reserved.