Cantaloop CGimlet - API Documentation, Version: 0.2.0, Date: 2002-05-13 21:30 CEST

org.cantaloop.cgimlet
Class OptionReader

java.lang.Object
  |
  +--org.cantaloop.cgimlet.OptionReader
All Implemented Interfaces:
Constants

public class OptionReader
extends java.lang.Object
implements Constants

Handlers can use a OptionReader to read configuration options. A options is a element which has a key and a value attribute, for example: <option name="input-dir" value="src"/>.

By default, options are stored in a Options instance. To customize this behaviour you can use a OptionSetter, which is invoked every time a option is read.

For a example of how to use an OptionReader have a look at the documentation of Options.

Version:
0.2.0 ($Revision: 1.11 $)
Author:
David Leuschner, Stefan Heimann

Field Summary
protected  OptionReaderConfigurator m_config
           
protected  Options m_opt
           
protected  org.dom4j.Element m_root
           
protected  OptionSetter m_setter
           
 
Fields inherited from interface org.cantaloop.cgimlet.Constants
LOGGER_TOPIC_PREFIX, PROJECT_NS, PROJECT_NS_URI, PROPERTY
 
Constructor Summary
OptionReader(OptionReaderConfigurator config, org.dom4j.Element root)
          Creates a new OptionReader instance.
OptionReader(OptionReaderConfigurator config, org.dom4j.Element root, Options opt)
          Creates a new OptionReader instance.
OptionReader(OptionReaderConfigurator config, Options opt)
          Creates a new OptionReader instance.
 
Method Summary
 java.lang.String getOption(java.lang.String key)
          Get the value of the option key.
 Options getOptions()
          Get the options instance the values are written to.
 org.dom4j.Element getRootElement()
          Get the root element of this OptionReader.
 void read()
          Read the options of the root element of this reader.
 void read(org.dom4j.Element root)
          Read the options of root.
 void setOption(java.lang.String key, java.lang.String value)
          Set option key to value.
 void setOptions(Options o)
          Set the options instance the values are written to.
 void setOptionSetter(OptionSetter setter)
          Set a handler which is called whenever a option has been read.
 void setRootElement(org.dom4j.Element root)
          Set the element that should be used as the root element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_root

protected org.dom4j.Element m_root

m_opt

protected Options m_opt

m_setter

protected OptionSetter m_setter

m_config

protected OptionReaderConfigurator m_config
Constructor Detail

OptionReader

public OptionReader(OptionReaderConfigurator config,
                    org.dom4j.Element root)
Creates a new OptionReader instance.
Parameters:
config - the configuration for this reader.
root - the element that contains the options.

OptionReader

public OptionReader(OptionReaderConfigurator config,
                    Options opt)
Creates a new OptionReader instance.
Parameters:
config - the configuration for this reader.
opt - the Options to store the values.

OptionReader

public OptionReader(OptionReaderConfigurator config,
                    org.dom4j.Element root,
                    Options opt)
Creates a new OptionReader instance.
Parameters:
config - the configuration for this reader.
root - the element that contains the options
opt - the Options to store the values.
Method Detail

setRootElement

public void setRootElement(org.dom4j.Element root)
Set the element that should be used as the root element.
Parameters:
root - an Element value

getRootElement

public org.dom4j.Element getRootElement()
Get the root element of this OptionReader.
Returns:
an Element value

setOptions

public void setOptions(Options o)
Set the options instance the values are written to.
Parameters:
m - a Option value

getOptions

public Options getOptions()
Get the options instance the values are written to.
Returns:
a Option value

setOptionSetter

public void setOptionSetter(OptionSetter setter)
Set a handler which is called whenever a option has been read. Setting this value to null means reverting to the default behaviour (writing the options into a Options instance).
Parameters:
setter - an OptionSetter value

getOption

public java.lang.String getOption(java.lang.String key)
Get the value of the option key.
Parameters:
key - a String value
Returns:
a String value

setOption

public void setOption(java.lang.String key,
                      java.lang.String value)
Set option key to value.
Parameters:
key - a String value
value - a String value
Returns:
a String value

read

public void read()
Read the options of the root element of this reader.
See Also:
read(Element)

read

public void read(org.dom4j.Element root)
Read the options of root. All directed children that have the attributes for key and value (specified in the constructor) are treated as options. Options that appear several times are overwritten

Copyright 2001, 2002 Stefan Heimann, David Leuschner. All rights reserved.