public abstract class OptionSet extends Object
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.
Modifier and Type | Field and Description |
---|---|
private Option |
head |
private boolean |
loggingChanges |
private Option |
tail |
Modifier | Constructor and Description |
---|---|
protected |
OptionSet()
Initialize the option set so that options can be created.
|
Modifier and Type | Method and Description |
---|---|
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.
|
private final boolean loggingChanges
protected OptionSet()
final String register(Option o, String name)
o
- The option to register.name
- the option's namepublic final Option getOption(String key)
null
if an option can not be found.key
- The (unique) option key.null
.public final Option getFirst()
null
if no options exist.public void logChange(Option o)
o
- The option that changedpublic void log(Option o)
o
- The option to log.public void logXml()
protected abstract void logValue(Option o, boolean forXml)
o
- The option.forXml
- Is this part of XML output?protected abstract void logString(String s)
s
- the string to logprotected abstract void logNewLine()
protected abstract String computeKey(String name)
name
- The option name.protected abstract void warn(Option o, String message)
o
- The responsible option.message
- The message associated with the warning.protected abstract void fail(Option o, String message)
o
- The responsible option.message
- The error message associated with the failure.protected abstract int bytesToPages(Extent bytes)
bytes
- The number of bytes.protected abstract Extent pagesToBytes(int pages)
pages
- the number of pages.