pygmy.core
Class ConfigOption

java.lang.Object
  extended by pygmy.core.ConfigOption

public class ConfigOption
extends java.lang.Object

This class is used by handlers or endpoints to tell the server which options are used to configure the object.


Constructor Summary
ConfigOption(java.lang.String propertyName, boolean required, java.lang.String helpString)
          This is used to create a required property.
ConfigOption(java.lang.String propertyName, java.lang.String helpString)
          This is used to create an optional property that defaults to null if unspecified.
ConfigOption(java.lang.String propertyName, java.lang.String defaultValue, java.lang.String helpString)
          This is used to create an optional property that has a supplied default value.
 
Method Summary
 java.lang.Boolean getBoolean(Server server, java.lang.String name)
          This is used to fetch the value of the property as a Boolean.
 java.lang.Integer getInteger(Server server, java.lang.String name)
          This is used to fetch the value of the property as an Integer.
 java.lang.String getName()
          The name of the configuration property that this ConfigOption was constructed with.
 java.lang.String getProperty(Server server, java.lang.String name)
          This is used to fetch the value of the property.
 java.lang.String toHelp()
          This method is used to return a user viewable help string in case an object was misconfigured.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigOption

public ConfigOption(java.lang.String propertyName,
                    java.lang.String helpString)
This is used to create an optional property that defaults to null if unspecified.

Parameters:
propertyName - the name of the property.
helpString - the help string shown to the user.

ConfigOption

public ConfigOption(java.lang.String propertyName,
                    java.lang.String defaultValue,
                    java.lang.String helpString)
This is used to create an optional property that has a supplied default value.

Parameters:
propertyName - the name of the property.
defaultValue - the default value used if this property is unspecified.
helpString - the help string shown to the user.

ConfigOption

public ConfigOption(java.lang.String propertyName,
                    boolean required,
                    java.lang.String helpString)
This is used to create a required property. There is no default supplied in the case where required is true. If you specify it as false it's the same as an optional property with no default.

Parameters:
propertyName - the name of the property.
required - Used to specify a required property. True for required, false for optional.
helpString - the help string shown to the user if nothing is specified.
Method Detail

getProperty

public java.lang.String getProperty(Server server,
                                    java.lang.String name)
This is used to fetch the value of the property. It's returned as a String. It will return the default property if it's not specified.

Parameters:
server - the Server object used by the system.
name - the name of the handler or endpoint instance.
Returns:
the value of the property or the default value if it was supplied in the constructor.

getBoolean

public java.lang.Boolean getBoolean(Server server,
                                    java.lang.String name)
This is used to fetch the value of the property as a Boolean. It will return the default property if it's not specified.

Parameters:
server - the Server object used by the system.
name - the name of the handler or endpoint instance.
Returns:
a Boolean value of the property or the default value if it was supplied in the constructor.

getInteger

public java.lang.Integer getInteger(Server server,
                                    java.lang.String name)
This is used to fetch the value of the property as an Integer. It will return the default property if it's not specified.

Parameters:
server - the Server object used by the system.
name - the name of the handler or endpoint instance.
Returns:
an Integer value of the property or the default value if it was supplied in the constructor.

toHelp

public java.lang.String toHelp()
This method is used to return a user viewable help string in case an object was misconfigured.

Returns:
the user viewable string for misconfigured properties.

getName

public java.lang.String getName()
The name of the configuration property that this ConfigOption was constructed with.

Returns:
the propery's name.