org.vmutil.options
Class OptionSet

java.lang.Object
  extended by org.vmutil.options.OptionSet
Direct Known Subclasses:
OptionSet

public abstract class OptionSet
extends Object

The abstract base class for all option sets.

Concrete instantiations of this class include logic.

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
private  Option head
           
private  boolean loggingChanges
           
private  Option tail
           
 
Constructor Summary
protected OptionSet()
          Initialize the option set so that options can be created.
 
Method Summary
protected abstract  int bytesToPages(Extent bytes)
          Convert bytes into pages, rounding up if necessary.
protected abstract  String computeKey(String name)
          Determine the VM specific key for a given option name.
protected abstract  void fail(Option o, String message)
          A fatal error occurred during the setting of an option.
 Option getFirst()
          Return the first option.
 Option getOption(String key)
          Using the VM determined key, look up the corresponding option, or return null if an option can not be found.
 void log(Option o)
          Log the option value in plain text.
 void logChange(Option o)
          Log an option change
protected abstract  void logNewLine()
          Print a new line.
protected abstract  void logString(String s)
          Log a string.
protected abstract  void logValue(Option o, boolean forXml)
          Format and log an option value.
 void logXml()
          Log the option values in XML.
 void logXml(Option o)
          Log the option value in XML.
protected abstract  Extent pagesToBytes(int pages)
          Convert from pages into bytes.
(package private)  String register(Option o, String name)
          Register the option to this set, computing its key in the process.
protected abstract  void warn(Option o, String message)
          A non-fatal error occurred during the setting of an option.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

head

private Option head

tail

private Option tail

loggingChanges

private boolean loggingChanges
Constructor Detail

OptionSet

protected OptionSet()
Initialize the option set so that options can be created.

Method Detail

register

final String register(Option o,
                      String name)
Register the option to this set, computing its key in the process.

Parameters:
o - The option to register.

getOption

public final Option getOption(String key)
Using the VM determined key, look up the corresponding option, or return null if an option can not be found.

Parameters:
key - The (unique) option key.
Returns:
The option, or null.

getFirst

public final Option getFirst()
Return the first option. This can be used with the getNext method to iterate through the options.

Returns:
The first option, or null if no options exist.

logChange

public void logChange(Option o)
Log an option change

Parameters:
o - The option that changed

log

public void log(Option o)
Log the option value in plain text.

Parameters:
o - The option to log.

logXml

public void logXml(Option o)
Log the option value in XML.

Parameters:
o - The option to log.

logXml

public void logXml()
Log the option values in XML.


logValue

protected abstract void logValue(Option o,
                                 boolean forXml)
Format and log an option value.

Parameters:
o - The option.
forXml - Is this part of XML output?

logString

protected abstract void logString(String s)
Log a string.


logNewLine

protected abstract void logNewLine()
Print a new line.


computeKey

protected abstract String computeKey(String name)
Determine the VM specific key for a given option name. Option names are space delimited with capitalised words (e.g. "GC Verbosity Level").

Parameters:
name - The option name.
Returns:
The VM specific key.

warn

protected abstract void warn(Option o,
                             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:
o - The responsible option.
message - The message associated with the warning.

fail

protected abstract void fail(Option o,
                             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:
o - The responsible option.
message - The error message associated with the failure.

bytesToPages

protected abstract int bytesToPages(Extent bytes)
Convert bytes into pages, rounding up if necessary.

Parameters:
bytes - The number of bytes.
Returns:
The corresponding number of pages.

pagesToBytes

protected abstract Extent pagesToBytes(int pages)
Convert from pages into bytes.

Parameters:
pages - the number of pages.
Returns:
The corresponding number of bytes.