ec.util
Class ParameterDatabase

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by ec.util.ParameterDatabase
All Implemented Interfaces:
IParameterDatabase, java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class ParameterDatabase
extends java.util.Properties
implements IParameterDatabase, java.io.Serializable

This extension of the Properties class allows you to set, get, and delete Parameters in a hierarchical tree-like database. The database consists of a list of Parameters, plus an array of "parent databases" which it falls back on when it can't find the Parameter you're looking for. Parents may also have arrays of parents, and so on..

The parameters are loaded from a Java property-list file, which is basically a collection of parameter=value pairs, one per line. Empty lines and lines beginning with # are ignored. These parameters and their values are case-sensitive , and whitespace is trimmed I believe.

An optional set of parameters, "parent. n ", where n are consecutive integers starting at 0, define the filenames of the database's parents.

An optional set of parameters, "print-params", specifies whether or not parameters should be printed as they are used (through one of the get(...) methods). If print-params is unset, or set to false or FALSE, nothing is printed. If set to non-false, then the parameters are printed prepended with a "P:" when their values are requested, "E:" when their existence is tested. Prior to the "P:" or "E:" you may see a "!" (meaning that the parameter isn't in the database), or a "<" (meaning that the parameter was a default parameter which was never looked up because the primary parameter contained the value).

When you create a ParameterDatabase using new ParameterDatabase(), it is created thus:

DATABASE:  database
FROM:  (empty)

When you create a ParameterDatabase using new ParameterDatabase( file ), it is created by loading the database file, and its parent file tree, thus:

DATABASE:  database  ->  parent0  +->  parent0  +->  parent0  +->  ....
FROM:  (empty)    (file)  |  (parent.0)  |  (parent.0)    ....
         |    +->  parent1  +->  ....
         |    |  (parent.1)    
         |    ....      
         |          
         +->  parent1  +->  ....    
         |  (parent.1)        
         ....          

When you create a ParameterDatabase using new ParameterDatabase( file,argv ), the preferred way, it is created thus:

DATABASE:  database  ->  parent0  +->  parent0  +->  parent0  +->  parent0  +->  ....
FROM:  (empty)   (argv)    (file)  |  (parent.0)  |  (parent.0)    ....
             |    +->  parent1  +->  ....
             |    |  (parent.1)    
             |    ....      
             |          
             +->  parent1  +->  ....    
             |  (parent.1)        
             ....          

...that is, the actual top database is empty, and stores parameters added programmatically; its parent is a database formed from arguments passed in on the command line; its parent is the parameter database which actually loads from foo. This allows you to programmatically add parameters which override those in foo, then delete them, thus bringing foo's parameters back in view.

Once a parameter database is loaded, you query it with the get methods. The database, then its parents, are searched until a match is found for your parameter. The search rules are thus: (1) the root database is searched first. (2) If a database being searched doesn't contain the data, it searches its parents recursively, starting with parent 0, then moving up, until all searches are exhausted or something was found. (3) No database is searched twice.

The various get methods all take two parameters. The first parameter is fetched and retrieved first. If that fails, the second one (known as the default parameter) is fetched and retrieved. You can pass in null for the default parameter if you don't have one.

You can test a parameter for existence with the exists methods.

You can set a parameter (in the topmost database only with the set command. The remove command removes a parameter from the topmost database only. The removeDeeply command removes that parameter from every database.

The values stored in a parameter database must not contain "#", "=", non-ascii values, or whitespace.

Note for JDK 1.1 . Finally recovering from stupendous idiocy, JDK 1.2 included parseDouble() and parseFloat() commands; now you can READ A FLOAT FROM A STRING without having to create a Float object first! Anyway, you will need to modify the getFloat() method below if you're running on JDK 1.1, but understand that large numbers of calls to the method may be inefficient. Sample JDK 1.1 code is given with those methods, but is commented out.

Version:
1.0
Author:
Sean Luke
See Also:
Serialized Form

Field Summary
 int printState
           
 
Fields inherited from class java.util.Properties
defaults
 
Fields inherited from interface ec.util.IParameterDatabase
C_HERE, PRINT_PARAMS, PS_NONE, PS_PRINT_PARAMS, PS_UNKNOWN, UNKNOWN_VALUE
 
Constructor Summary
ParameterDatabase()
          Creates an empty parameter database.
ParameterDatabase(java.util.Dictionary map)
          Creates a new parameter database from the given Dictionary.
ParameterDatabase(java.io.File filename)
          Creates a new parameter database tree from a given database file and its parent files.
ParameterDatabase(java.io.File filename, java.lang.String[] args)
          Creates a new parameter database from a given database file and argv list.
ParameterDatabase(java.io.InputStream stream)
          Creates a new parameter database loaded from the given stream.
ParameterDatabase(java.lang.String pathNameInJar, java.lang.Class jarResourceLocation)
          Creates a new parameter database loaded from the given string describing a file in a jar, in the context of a resource location (a class).
 
Method Summary
 void addListener(ParameterDatabaseListener l)
           
 javax.swing.tree.TreeModel buildTreeModel()
          Builds a TreeModel from the available property keys.
 java.io.File directoryFor(Parameter parameter)
          Searches down through databases to find the directory for the database which holds a given parameter.
 boolean exists(Parameter parameter)
          Returns true if parameter exist in the database
 boolean exists(Parameter parameter, Parameter defaultParameter)
          Returns true if either parameter or defaultParameter exists in the database
 java.io.File fileFor(Parameter parameter)
          Searches down through databases to find the parameter file which holds a given parameter.
 void fireParameterAccessed(Parameter parameter, java.lang.String value)
          Fires a parameter accessed event.
 void fireParameterSet(Parameter parameter, java.lang.String value)
          Fires a parameter set event.
 boolean getBoolean(Parameter parameter, Parameter defaultParameter, boolean defaultValue)
          Searches down through databases to find a given parameter; If the parameter does not exist, defaultValue is returned.
 java.lang.Class getClassForParameter(Parameter parameter, Parameter defaultParameter, java.lang.Class mustCastTosuperclass)
          Searches down through databases to find a given parameter.
 double getDouble(Parameter parameter, Parameter defaultParameter, double minValue)
          Searches down through databases to find a given parameter, whose value must be a double >= minValue.
 double getDouble(Parameter parameter, Parameter defaultParameter, double minValue, double maxValue)
          Searches down through databases to find a given parameter, whose value must be a double >= minValue and <= maxValue.
 double getDoubleWithDefault(Parameter parameter, Parameter defaultParameter, double defaultValue)
          Searches down through databases to find a given parameter, which must be a float.
 java.io.File getFile(Parameter parameter, Parameter defaultParameter)
          Searches down through the databases to find a given parameter, whose value must be an absolute or relative path name.
 float getFloat(Parameter parameter, Parameter defaultParameter, double minValue)
          Searches down through databases to find a given parameter, whose value must be a float >= minValue.
 float getFloat(Parameter parameter, Parameter defaultParameter, double minValue, double maxValue)
          Searches down through databases to find a given parameter, whose value must be a float >= minValue and <= maxValue.
 float getFloatWithDefault(Parameter parameter, Parameter defaultParameter, double defaultValue)
          Searches down through databases to find a given parameter, which must be a float.
 java.io.InputStream getInputStream(Parameter parameter, Parameter defaultParameter)
           
 java.lang.Object getInstanceForParameter(Parameter parameter, Parameter defaultParameter, java.lang.Class mustCastTosuperclass)
          Searches down through databases to find a given parameter, whose value must be a full Class name, and the class must be a descendent of but not equal to mustCastTosuperclass .
 java.lang.Object getInstanceForParameterEq(Parameter parameter, Parameter defaultParameter, java.lang.Class mustCastTosuperclass)
          Searches down through databases to find a given parameter, whose value must be a full Class name, and the class must be a descendent, or equal to, mustCastTosuperclass .
 int getInt(Parameter parameter, Parameter defaultParameter)
          Searches down through databases to find a given parameter, whose value must be an integer.
 int getInt(Parameter parameter, Parameter defaultParameter, int minValue)
          Searches down through databases to find a given parameter, whose value must be an integer >= minValue.
 int getIntWithDefault(Parameter parameter, Parameter defaultParameter, int defaultValue)
          Searches down through databases to find a given parameter, which must be an integer.
 int getIntWithMax(Parameter parameter, Parameter defaultParameter, int minValue, int maxValue)
          Searches down through databases to find a given parameter, whose value must be an integer >= minValue and <= maxValue.
 long getLong(Parameter parameter, Parameter defaultParameter)
          Searches down through databases to find a given parameter, whose value must be a long.
 long getLong(Parameter parameter, Parameter defaultParameter, long minValue)
          Searches down through databases to find a given parameter, whose value must be a long >= minValue.
 long getLong(Parameter parameter, Parameter defaultParameter, long minValue, long maxValue)
          Deprecated.  
 long getLongWithDefault(Parameter parameter, Parameter defaultParameter, long defaultValue)
          Searches down through databases to find a given parameter, which must be a long.
 long getLongWithMax(Parameter parameter, Parameter defaultParameter, long minValue, long maxValue)
          Searches down through databases to find a given parameter, whose value must be a long >= minValue and = < maxValue.
 java.util.Set getShadowedValues(Parameter parameter)
           
 java.lang.String getString(Parameter parameter, Parameter defaultParameter)
          Searches down through databases to find a given parameter.
 java.lang.String getStringWithDefault(Parameter parameter, Parameter defaultParameter, java.lang.String defaultValue)
          Searches down through databases to find a given parameter.
 void list(java.io.PrintStream p)
          Prints out all the parameters in the database, but not shadowed parameters.
 void list(java.io.PrintStream p, boolean listShadowed)
          Prints out all the parameters in the database.
 void list(java.io.PrintWriter p)
          Prints out all the parameters in the database, but not shadowed parameters.
 void list(java.io.PrintWriter p, boolean listShadowed)
          Prints out all the parameters in the database.
 void listAccessed(java.io.PrintWriter p)
          Prints out all the parameters marked as accessed ("gotten" by some getFoo(...) method), plus their values.
 void listGotten(java.io.PrintWriter p)
          Prints out all the parameters marked as used, plus their values.
 void listNotAccessed(java.io.PrintWriter p)
          Prints out all the parameters NOT marked as used, plus their values.
 void listNotGotten(java.io.PrintWriter p)
          Prints out all the parameters NOT marked as used, plus their values.
static void main(java.lang.String[] args)
          Test the ParameterDatabase
 java.util.Set<java.lang.String> parameterNameSet()
           
 void remove(Parameter parameter)
          Removes a parameter from the topmost database.
 void removeDeeply(Parameter parameter)
          Removes a parameter from the database and all its parent databases.
 void removeListener(ParameterDatabaseListener l)
           
 void set(Parameter parameter, java.lang.String value)
          Sets a parameter in the topmost database to a given value, trimmed of whitespace.
 void setObject(Parameter parameter, java.lang.Object value)
           
 java.lang.String toString()
           
 
Methods inherited from class java.util.Properties
getProperty, getProperty, load, loadFromXML, propertyNames, save, setProperty, store, storeToXML, storeToXML
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

printState

public int printState
Constructor Detail

ParameterDatabase

public ParameterDatabase()
Creates an empty parameter database.


ParameterDatabase

public ParameterDatabase(java.util.Dictionary map)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Creates a new parameter database from the given Dictionary. Both the keys and values will be run through toString() before adding to the dataase. Keys are parameters. Values are the values of the parameters. Beware that a ParameterDatabase is itself a Dictionary; but if you pass one in here you will only get the lowest-level elements. If parent.n are defined, parents will be attempted to be loaded -- that's the reason for the FileNotFoundException and IOException.

Throws:
java.io.FileNotFoundException
java.io.IOException

ParameterDatabase

public ParameterDatabase(java.lang.String pathNameInJar,
                         java.lang.Class jarResourceLocation)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Creates a new parameter database loaded from the given string describing a file in a jar, in the context of a resource location (a class). This approach uses resourceLocation.getResourceAsStream() to load the parameter file. If parent.n are defined, parents will be attempted to be loaded -- that's the reason for the FileNotFoundException and IOException.

Throws:
java.io.FileNotFoundException
java.io.IOException

ParameterDatabase

public ParameterDatabase(java.io.InputStream stream)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Creates a new parameter database loaded from the given stream. Non-relative parents are not permitted. If parent.n are defined, parents will be attempted to be loaded -- that's the reason for the FileNotFoundException and IOException.

Throws:
java.io.FileNotFoundException
java.io.IOException

ParameterDatabase

public ParameterDatabase(java.io.File filename)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Creates a new parameter database tree from a given database file and its parent files.

Throws:
java.io.FileNotFoundException
java.io.IOException

ParameterDatabase

public ParameterDatabase(java.io.File filename,
                         java.lang.String[] args)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Creates a new parameter database from a given database file and argv list. The top-level database is completely empty, pointing to a second database which contains the parameter entries stored in args, which points to a tree of databases constructed using ParameterDatabase(filename).

Throws:
java.io.FileNotFoundException
java.io.IOException
Method Detail

getInstanceForParameter

public java.lang.Object getInstanceForParameter(Parameter parameter,
                                                Parameter defaultParameter,
                                                java.lang.Class mustCastTosuperclass)
                                         throws ParamClassLoadException
Searches down through databases to find a given parameter, whose value must be a full Class name, and the class must be a descendent of but not equal to mustCastTosuperclass . Loads the class and returns an instance (constructed with the default constructor), or throws a ParamClassLoadException if there is no such Class. If the parameter is not found, the defaultParameter is used. The parameter chosen is marked "used".

Specified by:
getInstanceForParameter in interface IParameterDatabase
Throws:
ParamClassLoadException

getInstanceForParameterEq

public java.lang.Object getInstanceForParameterEq(Parameter parameter,
                                                  Parameter defaultParameter,
                                                  java.lang.Class mustCastTosuperclass)
                                           throws ParamClassLoadException
Searches down through databases to find a given parameter, whose value must be a full Class name, and the class must be a descendent, or equal to, mustCastTosuperclass . Loads the class and returns an instance (constructed with the default constructor), or throws a ParamClassLoadException if there is no such Class. The parameter chosen is marked "used".

Specified by:
getInstanceForParameterEq in interface IParameterDatabase
Throws:
ParamClassLoadException

getClassForParameter

public java.lang.Class getClassForParameter(Parameter parameter,
                                            Parameter defaultParameter,
                                            java.lang.Class mustCastTosuperclass)
                                     throws ParamClassLoadException
Searches down through databases to find a given parameter. The value associated with this parameter must be a full Class name, and the class must be a descendent of but not equal to mustCastTosuperclass . Loads and returns the associated Class, or throws a ParamClassLoadException if there is no such Class. If the parameter is not found, the defaultParameter is used. The parameter chosen is marked "used".

Specified by:
getClassForParameter in interface IParameterDatabase
Throws:
ParamClassLoadException

getBoolean

public boolean getBoolean(Parameter parameter,
                          Parameter defaultParameter,
                          boolean defaultValue)
Searches down through databases to find a given parameter; If the parameter does not exist, defaultValue is returned. If the parameter exists, and it is set to "false" (case insensitive), false is returned. Else true is returned. The parameter chosen is marked "used" if it exists.

Specified by:
getBoolean in interface IParameterDatabase

getInt

public int getInt(Parameter parameter,
                  Parameter defaultParameter)
           throws java.lang.NumberFormatException
Searches down through databases to find a given parameter, whose value must be an integer. It returns the value, else throws a NumberFormatException exception if there is an error in parsing the parameter. The parameter chosen is marked "used" if it exists. Integers may be in decimal or (if preceded with an X or x) in hexadecimal.

Specified by:
getInt in interface IParameterDatabase
Throws:
java.lang.NumberFormatException

getInt

public int getInt(Parameter parameter,
                  Parameter defaultParameter,
                  int minValue)
Searches down through databases to find a given parameter, whose value must be an integer >= minValue. It returns the value, or minValue-1 if the value is out of range or if there is an error in parsing the parameter. The parameter chosen is marked "used" if it exists. Integers may be in decimal or (if preceded with an X or x) in hexadecimal.

Specified by:
getInt in interface IParameterDatabase

getIntWithDefault

public int getIntWithDefault(Parameter parameter,
                             Parameter defaultParameter,
                             int defaultValue)
Searches down through databases to find a given parameter, which must be an integer. If there is an error in parsing the parameter, then default is returned. The parameter chosen is marked "used" if it exists. Integers may be in decimal or (if preceded with an X or x) in hexadecimal.

Specified by:
getIntWithDefault in interface IParameterDatabase

getIntWithMax

public int getIntWithMax(Parameter parameter,
                         Parameter defaultParameter,
                         int minValue,
                         int maxValue)
Searches down through databases to find a given parameter, whose value must be an integer >= minValue and <= maxValue. It returns the value, or minValue-1 if the value is out of range or if there is an error in parsing the parameter. The parameter chosen is marked "used" if it exists. Integers may be in decimal or (if preceded with an X or x) in hexadecimal.

Specified by:
getIntWithMax in interface IParameterDatabase

getFloat

public float getFloat(Parameter parameter,
                      Parameter defaultParameter,
                      double minValue)
Searches down through databases to find a given parameter, whose value must be a float >= minValue. If not, this method returns minvalue-1, else it returns the parameter value. The parameter chosen is marked "used" if it exists.

Specified by:
getFloat in interface IParameterDatabase
Parameters:
parameter - Primary parameter
defaultParameter - Default parameter
Returns:
Parameter value, or minValue-1 if the parameter doesn't exist or is out of range.

getFloatWithDefault

public float getFloatWithDefault(Parameter parameter,
                                 Parameter defaultParameter,
                                 double defaultValue)
Searches down through databases to find a given parameter, which must be a float. If there is an error in parsing the parameter, then default is returned. The parameter chosen is marked "used" if it exists.

Specified by:
getFloatWithDefault in interface IParameterDatabase

getFloat

public float getFloat(Parameter parameter,
                      Parameter defaultParameter,
                      double minValue,
                      double maxValue)
Searches down through databases to find a given parameter, whose value must be a float >= minValue and <= maxValue. If not, this method returns minvalue-1, else it returns the parameter value. The parameter chosen is marked "used" if it exists.

Specified by:
getFloat in interface IParameterDatabase

getDouble

public double getDouble(Parameter parameter,
                        Parameter defaultParameter,
                        double minValue)
Searches down through databases to find a given parameter, whose value must be a double >= minValue. If not, this method returns minvalue-1, else it returns the parameter value. The parameter chosen is marked "used" if it exists.

Specified by:
getDouble in interface IParameterDatabase

getDouble

public double getDouble(Parameter parameter,
                        Parameter defaultParameter,
                        double minValue,
                        double maxValue)
Searches down through databases to find a given parameter, whose value must be a double >= minValue and <= maxValue. If not, this method returns minvalue-1, else it returns the parameter value. The parameter chosen is marked "used" if it exists.

Specified by:
getDouble in interface IParameterDatabase

getDoubleWithDefault

public double getDoubleWithDefault(Parameter parameter,
                                   Parameter defaultParameter,
                                   double defaultValue)
Searches down through databases to find a given parameter, which must be a float. If there is an error in parsing the parameter, then default is returned. The parameter chosen is marked "used" if it exists.

Specified by:
getDoubleWithDefault in interface IParameterDatabase

getLong

public long getLong(Parameter parameter,
                    Parameter defaultParameter)
             throws java.lang.NumberFormatException
Searches down through databases to find a given parameter, whose value must be a long. It returns the value, else throws a NumberFormatException exception if there is an error in parsing the parameter. The parameter chosen is marked "used" if it exists. Longs may be in decimal or (if preceded with an X or x) in hexadecimal.

Specified by:
getLong in interface IParameterDatabase
Throws:
java.lang.NumberFormatException

getLong

public long getLong(Parameter parameter,
                    Parameter defaultParameter,
                    long minValue)
Searches down through databases to find a given parameter, whose value must be a long >= minValue. If not, this method returns errValue, else it returns the parameter value. The parameter chosen is marked "used" if it exists. Longs may be in decimal or (if preceded with an X or x) in hexadecimal.

Specified by:
getLong in interface IParameterDatabase

getLongWithDefault

public long getLongWithDefault(Parameter parameter,
                               Parameter defaultParameter,
                               long defaultValue)
Searches down through databases to find a given parameter, which must be a long. If there is an error in parsing the parameter, then default is returned. The parameter chosen is marked "used" if it exists. Longs may be in decimal or (if preceded with an X or x) in hexadecimal.

Specified by:
getLongWithDefault in interface IParameterDatabase

getLongWithMax

public long getLongWithMax(Parameter parameter,
                           Parameter defaultParameter,
                           long minValue,
                           long maxValue)
Searches down through databases to find a given parameter, whose value must be a long >= minValue and = < maxValue. If not, this method returns errValue, else it returns the parameter value. The parameter chosen is marked "used" if it exists. Longs may be in decimal or (if preceded with an X or x) in hexadecimal.

Specified by:
getLongWithMax in interface IParameterDatabase

getLong

public long getLong(Parameter parameter,
                    Parameter defaultParameter,
                    long minValue,
                    long maxValue)
Deprecated. 

Use getLongWithMax(...) instead. Searches down through databases to find a given parameter, whose value must be a long >= minValue and = < maxValue. If not, this method returns errValue, else it returns the parameter value. The parameter chosen is marked "used" if it exists. Longs may be in decimal or (if preceded with an X or x) in hexadecimal.

Specified by:
getLong in interface IParameterDatabase

getFile

public java.io.File getFile(Parameter parameter,
                            Parameter defaultParameter)
Searches down through the databases to find a given parameter, whose value must be an absolute or relative path name. If it is absolute, a File is made based on the path name. If it is relative, a file is made by resolving the path name with respect to the directory in which the file was which defined this ParameterDatabase in the ParameterDatabase hierarchy. If the parameter is not found, this returns null. The File is not checked for validity. The parameter chosen is marked "used" if it exists.

Specified by:
getFile in interface IParameterDatabase

getInputStream

public java.io.InputStream getInputStream(Parameter parameter,
                                          Parameter defaultParameter)
Specified by:
getInputStream in interface IParameterDatabase

getString

public java.lang.String getString(Parameter parameter,
                                  Parameter defaultParameter)
Searches down through databases to find a given parameter. Returns the parameter's value (trimmed) or null if not found or if the trimmed result is empty. The parameter chosen is marked "used" if it exists.

Specified by:
getString in interface IParameterDatabase

getStringWithDefault

public java.lang.String getStringWithDefault(Parameter parameter,
                                             Parameter defaultParameter,
                                             java.lang.String defaultValue)
Searches down through databases to find a given parameter. Returns the parameter's value trimmed of whitespace, or defaultValue.trim() if the result is not found or the trimmed result is empty.

Specified by:
getStringWithDefault in interface IParameterDatabase

addListener

public void addListener(ParameterDatabaseListener l)
Parameters:
l -

removeListener

public void removeListener(ParameterDatabaseListener l)
Parameters:
l -

fireParameterSet

public void fireParameterSet(Parameter parameter,
                             java.lang.String value)
Fires a parameter set event.

Parameters:
parameter -
value -

fireParameterAccessed

public void fireParameterAccessed(Parameter parameter,
                                  java.lang.String value)
Fires a parameter accessed event.

Parameters:
parameter -
value -

set

public void set(Parameter parameter,
                java.lang.String value)
Sets a parameter in the topmost database to a given value, trimmed of whitespace.

Specified by:
set in interface IParameterDatabase

setObject

public void setObject(Parameter parameter,
                      java.lang.Object value)
Specified by:
setObject in interface IParameterDatabase

listGotten

public void listGotten(java.io.PrintWriter p)
Prints out all the parameters marked as used, plus their values. If a parameter was listed as "used" but not's actually in the database, the value printed is UNKNOWN_VALUE (set to "?????")

Specified by:
listGotten in interface IParameterDatabase

listNotGotten

public void listNotGotten(java.io.PrintWriter p)
Prints out all the parameters NOT marked as used, plus their values.

Specified by:
listNotGotten in interface IParameterDatabase

listNotAccessed

public void listNotAccessed(java.io.PrintWriter p)
Prints out all the parameters NOT marked as used, plus their values.

Specified by:
listNotAccessed in interface IParameterDatabase

listAccessed

public void listAccessed(java.io.PrintWriter p)
Prints out all the parameters marked as accessed ("gotten" by some getFoo(...) method), plus their values. If this method ever prints UNKNOWN_VALUE ("?????"), that's a bug.

Specified by:
listAccessed in interface IParameterDatabase

exists

public boolean exists(Parameter parameter)
Returns true if parameter exist in the database

Specified by:
exists in interface IParameterDatabase

exists

public boolean exists(Parameter parameter,
                      Parameter defaultParameter)
Returns true if either parameter or defaultParameter exists in the database

Specified by:
exists in interface IParameterDatabase

getShadowedValues

public java.util.Set getShadowedValues(Parameter parameter)

directoryFor

public java.io.File directoryFor(Parameter parameter)
Searches down through databases to find the directory for the database which holds a given parameter. Returns the directory name or null if not found.

Specified by:
directoryFor in interface IParameterDatabase

fileFor

public java.io.File fileFor(Parameter parameter)
Searches down through databases to find the parameter file which holds a given parameter. Returns the filename or null if not found.

Specified by:
fileFor in interface IParameterDatabase

remove

public void remove(Parameter parameter)
Removes a parameter from the topmost database.

Specified by:
remove in interface IParameterDatabase

removeDeeply

public void removeDeeply(Parameter parameter)
Removes a parameter from the database and all its parent databases.


parameterNameSet

public java.util.Set<java.lang.String> parameterNameSet()
Specified by:
parameterNameSet in interface IParameterDatabase

list

public void list(java.io.PrintStream p,
                 boolean listShadowed)
Prints out all the parameters in the database. Useful for debugging. If listShadowed is true, each parameter is printed with the parameter database it's located in. If listShadowed is false, only active parameters are listed, and they're all given in one big chunk.

Specified by:
list in interface IParameterDatabase

list

public void list(java.io.PrintStream p)
Prints out all the parameters in the database, but not shadowed parameters.

Specified by:
list in interface IParameterDatabase
Overrides:
list in class java.util.Properties

list

public void list(java.io.PrintWriter p)
Prints out all the parameters in the database, but not shadowed parameters.

Specified by:
list in interface IParameterDatabase
Overrides:
list in class java.util.Properties

list

public void list(java.io.PrintWriter p,
                 boolean listShadowed)
Prints out all the parameters in the database. Useful for debugging. If listShadowed is true, each parameter is printed with the parameter database it's located in. If listShadowed is false, only active parameters are listed, and they're all given in one big chunk.

Specified by:
list in interface IParameterDatabase

toString

public java.lang.String toString()
Overrides:
toString in class java.util.Hashtable<java.lang.Object,java.lang.Object>

buildTreeModel

public javax.swing.tree.TreeModel buildTreeModel()
Builds a TreeModel from the available property keys.


main

public static void main(java.lang.String[] args)
                 throws java.io.FileNotFoundException,
                        java.io.IOException
Test the ParameterDatabase

Throws:
java.io.FileNotFoundException
java.io.IOException