|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectds.ov2.util.Option
public abstract class Option
Abstract command line option. Internally an option is almost a
record with one method. The record stores the option string and the
documentation. All this data is accessed from Parse_commandline
, which contains all the machinery for parsing
command lines. The only method in an option is matched
, which is called by Parse_commandline
when the
option has been recognized on the command line.
Clients need to override matched
with some code
that records the option and its possible arguments somewhere.
Field Summary | |
---|---|
String |
argument
A string describing arguments, if any. |
String |
explanation
The explanation of the option, to be printed in the usage information. |
String |
option
The literally option string as it appears on the command line. |
Constructor Summary | |
---|---|
Option(String option,
String argument,
String explanation)
Construct a new abstract option. |
Method Summary | |
---|---|
abstract void |
matched(Commandline cl)
Called by the option parsing machinery in Parse_commandline when this option has been recognized on the
command line. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final String option
public final String argument
explanation
for more information.
public final String explanation
-h print help -i n int argument nTo ease formatting of the usage information, option arguments (such as the
n
in the example) are kept seperately in
the field argument
. The explanation in the right hand
column is kept in this field.
See also Parse_commandline.usage()
.
Constructor Detail |
---|
public Option(String option, String argument, String explanation)
option
- the literal option string as it will appear on
the command lineargument
- a string describing any arguments of the
option, for the usuage information; might be null or the empty
string for no argumentsexplanation
- explanation for the usuage informationMethod Detail |
---|
public abstract void matched(Commandline cl)
Parse_commandline
when this option has been recognized on the
command line. When called the command line object points to the
next unprocessed element of the command line. If this option
has arguments, it must retrieve them from cl
and
advance the index therein such that it points to the next
unprocessed options when this method exits.
If the option is illegal in the current state or if its argument are missing or are of the wrong format, the method should print an appropriate error message and exit the program.
cl
- command line instance; its index points to the next
unprocessed command line element
Option_error
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |