|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
ObjectGetOpt
public class GetOpt
Java version of GNU getopt.
| Nested Class Summary | |
|---|---|
static class |
GetOpt.LongOption
A record used in a table of option descriptions passed to a constructor of GetOpt. |
| Field Summary | |
|---|---|
int |
longind
Index in longopts of a long-named option found. |
static int |
NO_ARG
A value for LongOption.has Arg meaning "option has no argument". |
static int |
OPT_ARG
A value for LongOption.has Arg meaning "option has an optional argument". |
String |
optarg
For communication from nextOpt() to the caller. |
boolean |
opterr
If set to false, do not print messages to System.err for unrecognized options. |
int |
optind
Index in argv of the next element to be scanned. |
char |
optopt
Set to an option character which was unrecognized. |
static int |
REQ_ARG
A value for LongOption.has Arg meaning "option has a required argument". |
| Constructor Summary | |
|---|---|
GetOpt(String progname,
String[] argv,
String shortopts)
Create a new option parser. |
|
GetOpt(String progname,
String[] argv,
String shortopts,
GetOpt.LongOption[] longopts)
Create a new option parser. |
|
GetOpt(String progname,
String[] argv,
String shortopts,
GetOpt.LongOption[] longopts,
boolean longonly)
Create a new option parser. |
|
| Method Summary | |
|---|---|
static void |
main(String[] ignore)
Main program for testing. |
int |
nextOpt()
Return the next option. |
| Methods inherited from class Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NO_ARG
public static final int REQ_ARG
public static final int OPT_ARG
public int optind
public int longind
public String optarg
public boolean opterr
public char optopt
| Constructor Detail |
|---|
public GetOpt(String progname,
String[] argv,
String shortopts,
GetOpt.LongOption[] longopts,
boolean longonly)
progname - the name of the program (for error messages)argv - an array of command-line argumentsshortopts - a string of short option flags. A single colon
following a flag indicates it has a mandatory argument; a double colon
indicates an optional argument.longopts - a table of long option descriptorslongonly - if true, indicates athat -flag should be treated as a
long flag, like --flag, rather than four short flags.
public GetOpt(String progname,
String[] argv,
String shortopts)
progname - the name of the program (for error messages)argv - an array of command-line argumentsshortopts - a string of short option flags. A single colon
following a flag indicates it has a mandatory argument; a double colon
indicates an optional argument.
public GetOpt(String progname,
String[] argv,
String shortopts,
GetOpt.LongOption[] longopts)
progname - the name of the program (for error messages)argv - an array of command-line argumentsshortopts - a string of short option flags. A single colon
following a flag indicates it has a mandatory argument; a double colon
indicates an optional argument.longopts - a table of long option descriptors| Method Detail |
|---|
public int nextOpt()
public static void main(String[] ignore)
ignore - ignored
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||