stomp.util
Class Prefs

java.lang.Object
  |
  +--stomp.util.Prefs

public class Prefs
extends java.lang.Object

Prefs manage all run-time describable attributes the system needs. Prefs should be defined in a runtime.prefs xml file which gets parsed at startup and made available through the getPref calls in in this class. Prefs are searched in the following order: the internal cache, the system properties, then finally, the runtime.prefs file.

Author:
Eric Lindauer

Field Summary
static java.lang.String DEFAULT_DELIMITER
           
 
Constructor Summary
Prefs(java.io.File xmlFile)
           
Prefs(java.lang.String prefsFileName)
           
Prefs(java.net.URL resource)
           
 
Method Summary
 void addPrefListener(PrefListener listener)
           
 boolean getPrefBoolean(java.lang.String prefName)
           
 boolean getPrefBoolean(java.lang.String prefName, boolean defaultValue)
           
 boolean getPrefBoolean(java.lang.String prefName, java.lang.Boolean defaultValue)
           
 boolean getPrefBoolean(java.lang.String prefName, boolean defaultValue, java.lang.String delimiter)
           
 boolean getPrefBoolean(java.lang.String prefName, java.lang.Boolean defaultValue, java.lang.String delimiter)
           
 boolean getPrefBoolean(java.lang.String prefName, java.lang.String delimiter)
          returns the boolean found in runtime.prefs at the specified location.
 java.lang.Class getPrefClass(java.lang.String name)
           
 java.lang.Class getPrefClass(java.lang.String name, java.lang.String delimiter)
           
 java.lang.Class[] getPrefClasses(java.lang.String name)
           
 java.lang.Class[] getPrefClasses(java.lang.String name, java.lang.String delimiter)
          returns an array of Class objects that are defined in Prefs at the given location
 double getPrefDouble(java.lang.String prefName)
           
 double getPrefDouble(java.lang.String prefName, double defaultValue)
           
 double getPrefDouble(java.lang.String prefName, java.lang.Double defaultValue)
           
 double getPrefDouble(java.lang.String prefName, double defaultValue, java.lang.String delimiter)
           
 double getPrefDouble(java.lang.String prefName, java.lang.Double defaultValue, java.lang.String delimiter)
           
 double getPrefDouble(java.lang.String prefName, java.lang.String delimiter)
          returns the double found in runtime.prefs at the specified location
 int getPrefInt(java.lang.String prefName)
           
 int getPrefInt(java.lang.String prefName, int defaultValue)
           
 int getPrefInt(java.lang.String prefName, java.lang.Integer defaultValue)
           
 int getPrefInt(java.lang.String prefName, java.lang.Integer defaultValue, java.lang.String delimiter)
           
 int getPrefInt(java.lang.String prefName, int defaultValue, java.lang.String delimiter)
           
 int getPrefInt(java.lang.String prefName, java.lang.String delimiter)
          returns the integer found in runtime.prefs at the specified location
 java.util.Map getPrefMap(java.lang.String name)
           
 java.util.Map getPrefMap(java.lang.String name, java.lang.String delimiter)
          returns a Map of ( node-tag, node-contents )
 java.lang.String getPrefString(java.lang.String prefName)
          parses the prefName and searches through the runtime.prefs file for the requested resource.
 java.lang.String getPrefString(java.lang.String prefName, java.lang.String defaultValue)
           
 java.lang.String getPrefString(java.lang.String prefName, java.lang.String defaultValue, java.lang.String delimiter)
           
 java.lang.String[] getPrefStrings(java.lang.String prefName)
           
 java.lang.String[] getPrefStrings(java.lang.String prefName, java.lang.String delimiter)
          parses the prefName and searches through the runtime.prefs file for the requested resource.
 void main(java.lang.String[] args)
           
 boolean prefExists(java.lang.String prefName)
           
 boolean prefExists(java.lang.String prefName, java.lang.String delimiter)
          returns true if the pref is findable in the cache in this ( either because it exists in runtime.prefs or because it has been set dynamically at runtime ), false otherwise.
 void reload()
          resets the prefs element representing the "runtime.prefs" file.
 void removePrefListener(PrefListener listener)
           
 void setPref(java.lang.String pref, java.lang.String value)
           
 void setPref(java.lang.String pref, java.lang.String value, java.lang.String delimiter)
          removes any cached values for the given pref, then places in value in the String cache.
static Prefs singleton()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DELIMITER

public static final java.lang.String DEFAULT_DELIMITER
See Also:
Constant Field Values
Constructor Detail

Prefs

public Prefs(java.lang.String prefsFileName)

Prefs

public Prefs(java.net.URL resource)

Prefs

public Prefs(java.io.File xmlFile)
Method Detail

singleton

public static Prefs singleton()

reload

public void reload()
resets the prefs element representing the "runtime.prefs" file. warning: calling reload is not thread-safe.


addPrefListener

public void addPrefListener(PrefListener listener)

removePrefListener

public void removePrefListener(PrefListener listener)

setPref

public void setPref(java.lang.String pref,
                    java.lang.String value)

setPref

public void setPref(java.lang.String pref,
                    java.lang.String value,
                    java.lang.String delimiter)
removes any cached values for the given pref, then places in value in the String cache. warning: manually setting a pref is not thread-safe.


prefExists

public boolean prefExists(java.lang.String prefName)

prefExists

public boolean prefExists(java.lang.String prefName,
                          java.lang.String delimiter)
returns true if the pref is findable in the cache in this ( either because it exists in runtime.prefs or because it has been set dynamically at runtime ), false otherwise.


getPrefInt

public int getPrefInt(java.lang.String prefName)

getPrefInt

public int getPrefInt(java.lang.String prefName,
                      java.lang.String delimiter)
returns the integer found in runtime.prefs at the specified location


getPrefInt

public int getPrefInt(java.lang.String prefName,
                      int defaultValue)

getPrefInt

public int getPrefInt(java.lang.String prefName,
                      int defaultValue,
                      java.lang.String delimiter)

getPrefInt

public int getPrefInt(java.lang.String prefName,
                      java.lang.Integer defaultValue)

getPrefInt

public int getPrefInt(java.lang.String prefName,
                      java.lang.Integer defaultValue,
                      java.lang.String delimiter)

getPrefDouble

public double getPrefDouble(java.lang.String prefName)

getPrefDouble

public double getPrefDouble(java.lang.String prefName,
                            java.lang.String delimiter)
returns the double found in runtime.prefs at the specified location


getPrefDouble

public double getPrefDouble(java.lang.String prefName,
                            double defaultValue)

getPrefDouble

public double getPrefDouble(java.lang.String prefName,
                            double defaultValue,
                            java.lang.String delimiter)

getPrefDouble

public double getPrefDouble(java.lang.String prefName,
                            java.lang.Double defaultValue)

getPrefDouble

public double getPrefDouble(java.lang.String prefName,
                            java.lang.Double defaultValue,
                            java.lang.String delimiter)

getPrefBoolean

public boolean getPrefBoolean(java.lang.String prefName)

getPrefBoolean

public boolean getPrefBoolean(java.lang.String prefName,
                              java.lang.String delimiter)
returns the boolean found in runtime.prefs at the specified location.


getPrefBoolean

public boolean getPrefBoolean(java.lang.String prefName,
                              boolean defaultValue)

getPrefBoolean

public boolean getPrefBoolean(java.lang.String prefName,
                              boolean defaultValue,
                              java.lang.String delimiter)

getPrefBoolean

public boolean getPrefBoolean(java.lang.String prefName,
                              java.lang.Boolean defaultValue)

getPrefBoolean

public boolean getPrefBoolean(java.lang.String prefName,
                              java.lang.Boolean defaultValue,
                              java.lang.String delimiter)

getPrefClasses

public java.lang.Class[] getPrefClasses(java.lang.String name)

getPrefClasses

public java.lang.Class[] getPrefClasses(java.lang.String name,
                                        java.lang.String delimiter)
returns an array of Class objects that are defined in Prefs at the given location


getPrefClass

public java.lang.Class getPrefClass(java.lang.String name)

getPrefClass

public java.lang.Class getPrefClass(java.lang.String name,
                                    java.lang.String delimiter)

getPrefMap

public java.util.Map getPrefMap(java.lang.String name)

getPrefMap

public java.util.Map getPrefMap(java.lang.String name,
                                java.lang.String delimiter)
returns a Map of ( node-tag, node-contents )


getPrefString

public java.lang.String getPrefString(java.lang.String prefName)
parses the prefName and searches through the runtime.prefs file for the requested resource.


getPrefString

public java.lang.String getPrefString(java.lang.String prefName,
                                      java.lang.String defaultValue)

getPrefString

public java.lang.String getPrefString(java.lang.String prefName,
                                      java.lang.String defaultValue,
                                      java.lang.String delimiter)

getPrefStrings

public java.lang.String[] getPrefStrings(java.lang.String prefName)

getPrefStrings

public java.lang.String[] getPrefStrings(java.lang.String prefName,
                                         java.lang.String delimiter)
parses the prefName and searches through the runtime.prefs file for the requested resource.


main

public void main(java.lang.String[] args)