Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.cantaloop.cgimlet
Class OptionReader  view OptionReader download OptionReader.java

java.lang.Object
  extended byorg.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:
@version@ ($Revision: 1.11 $)

Field Summary
protected  OptionReaderConfigurator m_config
           
private  org.cantaloop.tools.logging.Logger m_log
           
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

m_log

private org.cantaloop.tools.logging.Logger m_log
Constructor Detail

OptionReader

public OptionReader(OptionReaderConfigurator config,
                    org.dom4j.Element root)
Creates a new OptionReader instance.


OptionReader

public OptionReader(OptionReaderConfigurator config,
                    Options opt)
Creates a new OptionReader instance.


OptionReader

public OptionReader(OptionReaderConfigurator config,
                    org.dom4j.Element root,
                    Options opt)
Creates a new OptionReader instance.

Method Detail

setRootElement

public void setRootElement(org.dom4j.Element root)
Set the element that should be used as the root element.


getRootElement

public org.dom4j.Element getRootElement()
Get the root element of this OptionReader.


setOptions

public void setOptions(Options o)
Set the options instance the values are written to.


getOptions

public Options getOptions()
Get the options instance the values are written to.


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).


getOption

public java.lang.String getOption(java.lang.String key)
Get the value of the option key.


setOption

public void setOption(java.lang.String key,
                      java.lang.String value)
Set option key to value.


read

public void read()
Read the options of the root element of this reader.


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