Common Parameter Processing Code

The package "parameter" provides a uniform parameter processing model for use in Applets, Applications, and other contexts. This is used in IDVI to handle applet and application parameters, but also to handle retrieving attributes from html tags which appear in html: specials and retrieving arguments to psfile specials.
  1. ParameterProcessor - provides functions such as getBoolean, getInteger, getString, getURL, getColor, getHashtable, getArray, and getVector. Each has a version which throws a ParameterMissingException when the parameter is not present and a version which returns a default value specified by the caller.

  2. ParameterApplet - an applet base class which provides a ParameterProcessor called parameter. Code looks like "foo = parameter.getInteger( "foo", 0 );".

  3. ParameterApplication - an application base class which provides a ParameterProcessor called parameter. Code looks just like it does for a ParameterApplet. The derived application class must call init( String[ ] ) with the list of arguments to the application. Arguments are assumed to appear in the form "-name value" on the command line. A single unnamed parameter is allowed, and can be retrieved as the parameter with name "".

  4. ParameterException - base exception class thrown by the ParameterProcessor class. Has derived classes ParameterMissingException and ParameterValueException.

  5. ParameterStub - interface class used by the ParameterProcessor class. A ParameterStub must provide the single method GetParameter( String ), which returns NULL for a missing parameter and the string value of the parameter otherwise. A ParameterProcessor can be constructed on top of any ParameterStub.

  6. HashtableParameterStub - puts a ParameterStub wrapper around a Hashtable. Be careful to build the hashtable with all keys in lower case, since parameter names are converted to lower case before lookup.

    It would be useful to add a PutParameter function to this class, which would lowercase the key before putting it into the hashtable.

  7. ParameterUnionStub - merge the parameter lists of several ParameterStubs.

  8. ParameterExpandStub - before returning a parameter value, scan it for variable substitutions of the form $variable or ${variable}, replacing these with values from a ParameterProcessor. If the ParameterProcessor is using the ParameterExpandStub as its ParameterStub, then recursive substitution is done. There is a check for runaway recursion.

    This class is used to implement macro expansion when building per-page html files from templates.