|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcommon.cmdline.AbstractOption
public abstract class AbstractOption
Abstract implementation of the Option interface that takes care of some bookkeeping and error checking.
Field Summary | |
---|---|
protected static int |
DOC_OFFSET
Offset for documentation strings in usage strings. |
protected java.util.List |
longForms
List of String objects that are long forms of this option. |
protected boolean |
occurred
True if recordOccurrence has already been called on this option. |
protected java.util.List |
shortForms
List of Character objects that are short forms of this option. |
Constructor Summary | |
---|---|
AbstractOption(java.lang.String shortForm,
java.lang.String longForm)
Creates an option. |
Method Summary | |
---|---|
java.util.List |
getLongForms()
Returns the long forms of this option. |
java.util.List |
getShortForms()
Returns the short (single-character) forms of this option. |
void |
recordOccurrence(java.lang.String form,
java.lang.String valueStr)
This default implementation prints a warning if this option has already been occurred. |
java.lang.String |
toString()
|
boolean |
wasPresent()
Returns true if any form of this option occurred on the command line. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface common.cmdline.Option |
---|
expectsValue, getUsageString |
Field Detail |
---|
protected static final int DOC_OFFSET
getUsageString
should pad their return values with
spaces so that the documentation string begins at this offset.
protected java.util.List shortForms
protected java.util.List longForms
protected boolean occurred
Constructor Detail |
---|
public AbstractOption(java.lang.String shortForm, java.lang.String longForm)
shortForm
- single-character form of the option, or null if
the option has no single-character formlongForm
- long form of the option, or null if the option has
no long form
java.lang.IllegalArgumentException
- if shortForm
is a
string of length other than 1
java.lang.IllegalArgumentException
- if longForm
is an
empty string
java.lang.IllegalArgumentException
- if both shortForm
and longForm
are nullMethod Detail |
---|
public java.util.List getShortForms()
Option
getShortForms
in interface Option
public java.util.List getLongForms()
Option
getLongForms
in interface Option
public void recordOccurrence(java.lang.String form, java.lang.String valueStr)
occurred
member variable to true. However, it does not parse or record
the value.
recordOccurrence
in interface Option
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 boolean wasPresent()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |