jautil
Class BasicOptionSet

java.lang.Object
  extended by jautil.BasicOptionSet

public class BasicOptionSet
extends java.lang.Object

A BasicOptionSet is a basic collection of options settings, with an associated JA Preferences node, and with a back up options set, either or both of which may be null. The option set is represented as a Java Properties set; this set is initialised at construction time from the associated Preferences node, and optionally from the properties at a given URL.


Field Summary
static java.lang.String NULL_REP
          Representation for null property value.
 
Constructor Summary
BasicOptionSet(BasicOptionSet backup, java.net.URL baseurl, java.util.Properties props)
          Constructs a simple BasicOptionSet with the given backup option set, base url and defining properties, but with no key validator, preferences handler or preferences node.
BasicOptionSet(BasicOptionSet backup, java.net.URL baseurl, java.net.URL propsurl, JAPreferencesHandler japhdlr, java.lang.String prefsname)
          BasicOptionSet constructor with a null valid keys filter and no preferences update.
BasicOptionSet(BasicOptionSet backup, java.net.URL baseurl, java.net.URL propsurl, JAPreferencesHandler japhdlr, java.lang.String prefsname, boolean updateprefs)
          BasicOptionSet constructor with a null valid keys filter.
BasicOptionSet(JAOptions.KeyChecker keychckr, BasicOptionSet backup, java.net.URL baseurl, java.net.URL propsurl, JAPreferencesHandler japhdlr, java.lang.String prefsname, boolean updateprefs)
          BasicOptionSet constructor.
BasicOptionSet(java.net.URL baseurl, java.net.URL propsurl, JAPreferencesHandler japhdlr, java.lang.String prefsname)
          BasicOptionSet constructor with a null valid keys filter, a null back-up set, and no preferences update.
BasicOptionSet(java.net.URL baseurl, java.net.URL propsurl, JAPreferencesHandler japhdlr, java.lang.String prefsname, boolean updateprefs)
          BasicOptionSet constructor with a null valid keys filter and a null back-up set.
 
Method Summary
static java.lang.String checkForNull(java.lang.String prop)
          Returns the given property string value unless it is a string representation of null, in which case null is returned; the empty string and the string "null" and its case-insensitive invariants are taken to be valid representations of null.
 java.lang.String getBaseURLProperty(java.lang.String key)
          Performs a base URL look-up, just as getURLProperty(String), except that the result is guaranteed to be valid as a base URL, by appending a trailing slash character if necessary.
 java.lang.String getStringProperty(java.lang.String key)
          Returns the string value of the property with the given key, or null if there is none.
 java.lang.String getURLProperty(java.lang.String key)
          Looks up the URL property in this option set with the given key, and returns the result as a string; if found the URL is resolved against this option set's base URL, but any URL retrieved from the back-up option set is resolved against that set's base URL; the result is null if the look up fails.
 void updateStringProperty(java.lang.String key, java.lang.String value)
          Updates this option set's properties and the associated preferences node with the given key-value pair, provided the key is valid for this option set.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_REP

public static final java.lang.String NULL_REP
Representation for null property value.

See Also:
Constant Field Values
Constructor Detail

BasicOptionSet

public BasicOptionSet(BasicOptionSet backup,
                      java.net.URL baseurl,
                      java.util.Properties props)
Constructs a simple BasicOptionSet with the given backup option set, base url and defining properties, but with no key validator, preferences handler or preferences node.


BasicOptionSet

public BasicOptionSet(java.net.URL baseurl,
                      java.net.URL propsurl,
                      JAPreferencesHandler japhdlr,
                      java.lang.String prefsname)
BasicOptionSet constructor with a null valid keys filter, a null back-up set, and no preferences update.

Parameters:
baseurl - Base URL, used to resolve URLs looked up in this option set.
propsurl - URL for the properties to be included in this option set; may be null.
japhdlr - JA Preferences handler to be used by this option set.
prefsname - Name of the JA preferences node associated with this option set.

BasicOptionSet

public BasicOptionSet(BasicOptionSet backup,
                      java.net.URL baseurl,
                      java.net.URL propsurl,
                      JAPreferencesHandler japhdlr,
                      java.lang.String prefsname)
BasicOptionSet constructor with a null valid keys filter and no preferences update.

Parameters:
backup - Back-up option set, used when look-up in this set fails; may be null.
baseurl - Base URL, used to resolve URLs looked up in this option set.
propsurl - URL for the properties to be included in this option set; may be null.
japhdlr - JA Preferences handler to be used by this option set.
prefsname - Name of the JA preferences node associated with this option set.

BasicOptionSet

public BasicOptionSet(java.net.URL baseurl,
                      java.net.URL propsurl,
                      JAPreferencesHandler japhdlr,
                      java.lang.String prefsname,
                      boolean updateprefs)
BasicOptionSet constructor with a null valid keys filter and a null back-up set.

Parameters:
baseurl - Base URL, used to resolve URLs looked up in this option set.
propsurl - URL for the properties to be included in this option set; may be null.
japhdlr - JA Preferences handler to be used by this option set.
prefsname - Name of the JA preferences node associated with this option set.
updateprefs - Flag indicating whether or not the preferences node associated with this set is to be permanently updated with any newly loaded property definitions in this set.

BasicOptionSet

public BasicOptionSet(BasicOptionSet backup,
                      java.net.URL baseurl,
                      java.net.URL propsurl,
                      JAPreferencesHandler japhdlr,
                      java.lang.String prefsname,
                      boolean updateprefs)
BasicOptionSet constructor with a null valid keys filter.

Parameters:
backup - Back-up option set, used when look-up in this set fails; may be null.
baseurl - Base URL, used to resolve URLs looked up in this option set.
propsurl - URL for the properties to be included in this option set; may be null.
japhdlr - JA Preferences handler to be used by this option set.
prefsname - Name of the JA preferences node associated with this option set.
updateprefs - Flag indicating whether or not the preferences node associated with this set is to be permanently updated with any newly loaded property definitions in this set.

BasicOptionSet

public BasicOptionSet(JAOptions.KeyChecker keychckr,
                      BasicOptionSet backup,
                      java.net.URL baseurl,
                      java.net.URL propsurl,
                      JAPreferencesHandler japhdlr,
                      java.lang.String prefsname,
                      boolean updateprefs)
BasicOptionSet constructor.

Parameters:
keychckr - Valid keys checker for this option set; may be null, meaning no filter.
backup - Back-up option set, used when look-up in this set fails; may be null.
baseurl - Base URL, used to resolve URLs looked up in this option set.
propsurl - URL for the properties to be included in this option set; may be null.
japhdlr - JA Preferences handler to be used by this option set.
prefsname - Name of the JA preferences node associated with this option set.
updateprefs - Flag indicating whether or not the preferences node associated with this set is to be permanently updated with any newly loaded property definitions in this set.
Method Detail

updateStringProperty

public void updateStringProperty(java.lang.String key,
                                 java.lang.String value)
Updates this option set's properties and the associated preferences node with the given key-value pair, provided the key is valid for this option set.


getStringProperty

public java.lang.String getStringProperty(java.lang.String key)
Returns the string value of the property with the given key, or null if there is none.


getURLProperty

public java.lang.String getURLProperty(java.lang.String key)
Looks up the URL property in this option set with the given key, and returns the result as a string; if found the URL is resolved against this option set's base URL, but any URL retrieved from the back-up option set is resolved against that set's base URL; the result is null if the look up fails.


getBaseURLProperty

public java.lang.String getBaseURLProperty(java.lang.String key)
Performs a base URL look-up, just as getURLProperty(String), except that the result is guaranteed to be valid as a base URL, by appending a trailing slash character if necessary.


checkForNull

public static java.lang.String checkForNull(java.lang.String prop)
Returns the given property string value unless it is a string representation of null, in which case null is returned; the empty string and the string "null" and its case-insensitive invariants are taken to be valid representations of null.