org.vmutil.options
Class Option

java.lang.Object
  extended by org.vmutil.options.Option
Direct Known Subclasses:
AddressOption, BooleanOption, EnumOption, FloatOption, IntOption, MicrosecondsOption, PagesOption, StringOption

public abstract class Option
extends Object

The abstract base class for all options. This class also has the static interfaces to access the options system to set option values.

All options within the system should have a unique name. No two options shall have a name that is the same when a case insensitive comparison between the names with spaces removed is performed. Only basic alphanumeric characters and spaces are allowed.

The VM is required to provide a one way mapping function that takes the name and creates a VM style name, such as mapping "No Finalizer" to noFinalizer. The VM may not remove any letters when performing this mapping but may remove spaces and change the case of any character.


Field Summary
static int ADDRESS_OPTION
           
static int BOOLEAN_OPTION
           
private  String description
           
static int ENUM_OPTION
           
static int FLOAT_OPTION
           
static int INT_OPTION
           
private  String key
           
static int MICROSECONDS_OPTION
           
private  String name
           
private  Option next
           
static int PAGES_OPTION
           
static int RAW
           
static int READABLE
           
protected  OptionSet set
           
static int STRING_OPTION
           
private  int type
           
static int XML
           
 
Constructor Summary
protected Option(OptionSet set, int type, String name, String description)
          Construct a new option.
 
Method Summary
protected  void fail(String message)
          A fatal error occurred during the setting of an option.
protected  void failIf(boolean condition, String message)
          Fail if a specified condition is met.
 String getDescription()
          Return the option description.
 String getKey()
          Return the VM determined key for an option
 String getName()
          Return the name for the option.
 Option getNext()
          Return the next option in the linked list.
 int getType()
          Return the type of the option.
(package private)  void setNext(Option o)
          Update the next pointer in the Option chain.
protected  void validate()
          This is a validation method that can be implemented by leaf option classes to provide additional validation.
protected  void warn(String message)
          A non-fatal error occurred during the setting of an option.
protected  void warnIf(boolean condition, String message)
          Warn if a specified condition is met.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOOLEAN_OPTION

public static final int BOOLEAN_OPTION
See Also:
Constant Field Values

STRING_OPTION

public static final int STRING_OPTION
See Also:
Constant Field Values

ENUM_OPTION

public static final int ENUM_OPTION
See Also:
Constant Field Values

INT_OPTION

public static final int INT_OPTION
See Also:
Constant Field Values

PAGES_OPTION

public static final int PAGES_OPTION
See Also:
Constant Field Values

MICROSECONDS_OPTION

public static final int MICROSECONDS_OPTION
See Also:
Constant Field Values

FLOAT_OPTION

public static final int FLOAT_OPTION
See Also:
Constant Field Values

ADDRESS_OPTION

public static final int ADDRESS_OPTION
See Also:
Constant Field Values

READABLE

public static final int READABLE
See Also:
Constant Field Values

RAW

public static final int RAW
See Also:
Constant Field Values

XML

public static final int XML
See Also:
Constant Field Values

type

private int type

name

private String name

description

private String description

key

private String key

next

private Option next

set

protected OptionSet set
Constructor Detail

Option

protected Option(OptionSet set,
                 int type,
                 String name,
                 String description)
Construct a new option. This also calls the VM to map the option's name into a unique option key and links it onto the option list.

Parameters:
set - The option set this option belongs to.
type - The option type as defined in this class.
name - The unique name of the option.
description - A short description of the option and purpose.
Method Detail

getKey

public String getKey()
Return the VM determined key for an option

Returns:
The key.

setNext

void setNext(Option o)
Update the next pointer in the Option chain.


getNext

public Option getNext()
Return the next option in the linked list.

Returns:
The next option or null if this is the last option.

getName

public String getName()
Return the name for the option.

Returns:
The option name.

getDescription

public String getDescription()
Return the option description.

Returns:
The option description.

getType

public int getType()
Return the type of the option.

Returns:
The option type.

validate

protected void validate()
This is a validation method that can be implemented by leaf option classes to provide additional validation. This should not be implemented at other levels within the hierarchy to avoid confusion. The validate method works against the current value of the option (post-set).


fail

protected void fail(String message)
A fatal error occurred during the setting of an option. This method calls into the VM and is required to cause the system to stop.

Parameters:
message - The error message associated with the failure.

failIf

protected void failIf(boolean condition,
                      String message)
Fail if a specified condition is met.

Parameters:
condition - The condition that indicates failure.
message - The error message associated with the failure.

warn

protected void warn(String message)
A non-fatal error occurred during the setting of an option. This method calls into the VM and shall not cause the system to stop.

Parameters:
message - The message associated with the warning.

warnIf

protected void warnIf(boolean condition,
                      String message)
Warn if a specified condition is met.

Parameters:
condition - The condition that indicates warning.
message - The message associated with the warning.