|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcommon.cmdline.AbstractOption
common.cmdline.DoubleOption
public class DoubleOption
Option that takes real values. If this option occurs with a value that is not a valid real number, this class prints an error message and exits the program. If the option occurs more than once on a command line, this class prints a warning and ignores all but the last occurrence.
Field Summary |
---|
Fields inherited from class common.cmdline.AbstractOption |
---|
DOC_OFFSET, longForms, occurred, shortForms |
Constructor Summary | |
---|---|
DoubleOption(java.lang.String shortForm,
java.lang.String longForm,
double def,
java.lang.String docStr)
Creates a real-valued option and registers it with the Parser class. |
Method Summary | |
---|---|
boolean |
expectsValue()
Returns true if this option expects a value on the command line. |
java.lang.String |
getUsageString()
Returns a string that documents the option. |
double |
getValue()
Returns the value specified on the command line for this option, or the default value if the option did not occur. |
void |
recordOccurrence(java.lang.String form,
java.lang.String valueStr)
This default implementation prints a warning if this option has already been occurred. |
Methods inherited from class common.cmdline.AbstractOption |
---|
getLongForms, getShortForms, toString, wasPresent |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DoubleOption(java.lang.String shortForm, java.lang.String longForm, double def, java.lang.String docStr)
shortForm
- single-character form of this option, or null for
an option with no short formlongForm
- long form of this option, or null for an option
with no long form.def
- default value to return if the option does not occurdocStr
- short (preferably less than 40 characters)
string specifying what happens when this option's
value is "<x>"Method Detail |
---|
public boolean expectsValue()
Option
public void recordOccurrence(java.lang.String form, java.lang.String valueStr)
AbstractOption
occurred
member variable to true. However, it does not parse or record
the value.
recordOccurrence
in interface Option
recordOccurrence
in class AbstractOption
form
- specifies the particular long or short form of the
option that was usedvalueStr
- the given value, or null if no value was given.
The parser will only pass null for this parameter
if expectsValue
returns false;
otherwise, if the value is missing, the parser
will not call this method.public java.lang.String getUsageString()
Option
public double getValue()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |