gov.lanl.Utility
Class ConfigProperties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--java.util.Properties
                    |
                    +--gov.lanl.Utility.ConfigProperties
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Direct Known Subclasses:
PrintableConfigProperties

public class ConfigProperties
extends java.util.Properties

Extension of Properties class to support command line specification of properties

See Also:
Serialized Form
 

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
ConfigProperties()
          Constructor declaration which adds the System properties to the Properties
ConfigProperties(java.applet.Applet app)
           
ConfigProperties(java.util.ResourceBundle bundle)
          Initialize the class from a ResourceBundle
ConfigProperties(java.lang.String[] args)
           
ConfigProperties(java.lang.String default_file, java.lang.String[] args)
          initialize the class using a default_file and arguments
 
Method Summary
 java.lang.String getProp(java.lang.String key)
          return Property corresponding to key
 java.lang.String getProp(java.lang.String key, java.lang.String defaultValue)
          get a Property with a method that works for applets
 java.lang.String[] getPropertyTuple(java.lang.String key)
          Get the value of the property with the given key, splitting it on the tuple delimiter.
 java.lang.String[] getPropertyTuple(java.lang.String key, int size)
          Get the value of the property with the given key, splitting it on the tuple delimiter.
 void parseLine(java.lang.String line)
          Parse the input line with # and // as comments to populate the properties
 void readFile(java.lang.String file)
          read the file and parse it into properties
 void setProperties(java.util.ResourceBundle bundle)
          set the properties from a ResourceBundle
 void setProperties(java.lang.String default_file)
          set properties from default_file
 void setProperties(java.lang.String default_file, java.lang.String[] args)
          set properties from default_file and from commandline
 
Methods inherited from class java.util.Properties
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store
 
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, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigProperties

public ConfigProperties()
Constructor declaration which adds the System properties to the Properties

See Also:

ConfigProperties

public ConfigProperties(java.lang.String[] args)
Parameters:
args -

ConfigProperties

public ConfigProperties(java.applet.Applet app)
Parameters:
app -

ConfigProperties

public ConfigProperties(java.util.ResourceBundle bundle)
Initialize the class from a ResourceBundle

Parameters:
bundle - which is read to add properties

ConfigProperties

public ConfigProperties(java.lang.String default_file,
                        java.lang.String[] args)
initialize the class using a default_file and arguments

Parameters:
default_file - to be read
args - String array with command line arguments to be parsed
Method Detail

setProperties

public void setProperties(java.util.ResourceBundle bundle)
set the properties from a ResourceBundle

Parameters:
bundle - which is read to add properties

setProperties

public void setProperties(java.lang.String default_file)
set properties from default_file


setProperties

public void setProperties(java.lang.String default_file,
                          java.lang.String[] args)
set properties from default_file and from commandline

Parameters:
default_file -
args - String array containing -propertyname value pairs

readFile

public void readFile(java.lang.String file)
read the file and parse it into properties

Parameters:
file -

parseLine

public void parseLine(java.lang.String line)
Parse the input line with # and // as comments to populate the properties

Parameters:
line - to be parsed

getProp

public java.lang.String getProp(java.lang.String key)
return Property corresponding to key

Parameters:
key -
Returns:
value of Property

getProp

public java.lang.String getProp(java.lang.String key,
                                java.lang.String defaultValue)
get a Property with a method that works for applets

Parameters:
key -
defaultValue -
Returns:

getPropertyTuple

public java.lang.String[] getPropertyTuple(java.lang.String key)
Get the value of the property with the given key, splitting it on the tuple delimiter. A property of the form "a;b;c" will be returned as an array of three strings "a", "b", and "c"

Parameters:
key - Name of property to get
Returns:
Array of Strings, each containing a part of the property tuple

getPropertyTuple

public java.lang.String[] getPropertyTuple(java.lang.String key,
                                           int size)
Get the value of the property with the given key, splitting it on the tuple delimiter. A property of the form "a;b;c" will be returned as an array of three strings "a", "b", and "c"

Parameters:
key - Name of property to get
size - length of array to be returned, or if -1, determined by number of tokens
Returns:
Array of Strings, each containing a part of the property tuple