org.hecl
Class Properties

java.lang.Object
  extended by org.hecl.Properties
Direct Known Subclasses:
MethodProps

public class Properties
extends java.lang.Object

The Properties class is used to parse command line arguments. Its basic usage pattern is like so: a new Properties is instantiated with default properties and values, then setProps is called with argv. At that point the rest of the command can go on, and for every prop that's needed, it can be fetched with getProp.

Version:
1.0
Author:
David N. Welton

Field Summary
protected  java.util.Hashtable props
           
 
Constructor Summary
Properties()
          Creates a new Properties instance with no default properties.
Properties(java.lang.Object[] defaultprops)
          Creates a new Properties instance with default properties and their values.
 
Method Summary
 void delProp(java.lang.String name)
          delProp removes a property from the property set.
 boolean existsProp(java.lang.String name)
          The existsProp method is used to determine if a property exists or not.
 Thing getAndDelProp(java.lang.String name)
          The getAndDelProp method fetches and deletes the value associated with 'name', or returns null if there is no value associated with it.
 Thing getProp(java.lang.String name)
          The getProp method fetches the value of a property.
 Thing getProp(java.lang.String name, Thing defaultVal)
          The getProp method with two arguments fetches the value of the property given by 'name', or, if that does not exist, returns a default value.
 Thing[] getProps()
          getProps converts the properties back into an array of Things.
 boolean isEmpty()
          isEmpty test if property set is empty.
 void setProp(java.lang.String name, Thing val)
          The setProp method sets a single property to some value.
 void setProps(Thing[] argv, int offset)
          The setProps method sets properties with their values from the command line argv.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

props

protected java.util.Hashtable props
Constructor Detail

Properties

public Properties()
Creates a new Properties instance with no default properties.


Properties

public Properties(java.lang.Object[] defaultprops)
Creates a new Properties instance with default properties and their values.

Parameters:
defaultprops - an Object[] value
Method Detail

setProps

public void setProps(Thing[] argv,
                     int offset)
              throws HeclException
The setProps method sets properties with their values from the command line argv. The number of Things handled must be even.

Parameters:
argv - a Thing[] value
offset - an int value
Throws:
HeclException - if an error occurs

setProp

public void setProp(java.lang.String name,
                    Thing val)
The setProp method sets a single property to some value.

Parameters:
name - a String value
val - a Thing value

getProp

public Thing getProp(java.lang.String name)
The getProp method fetches the value of a property.

Parameters:
name - a String value
Returns:
a Thing value

getProp

public Thing getProp(java.lang.String name,
                     Thing defaultVal)
The getProp method with two arguments fetches the value of the property given by 'name', or, if that does not exist, returns a default value.

Parameters:
name - a String value
defaultVal - a Thing value
Returns:
a Thing value

existsProp

public boolean existsProp(java.lang.String name)
The existsProp method is used to determine if a property exists or not.

Parameters:
name - a String value
Returns:
a boolean value

getAndDelProp

public Thing getAndDelProp(java.lang.String name)
The getAndDelProp method fetches and deletes the value associated with 'name', or returns null if there is no value associated with it.

Parameters:
name - a String value
Returns:
a Thing value

delProp

public void delProp(java.lang.String name)
delProp removes a property from the property set.

Parameters:
name - a String value

getProps

public Thing[] getProps()
getProps converts the properties back into an array of Things.

Returns:
an array of Things, being property name and property value.

isEmpty

public boolean isEmpty()
isEmpty test if property set is empty.

Returns:
true if it's empty, flase otherwise.