|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.martiansoftware.jsap.JSAP
com.martiansoftware.jsap.SimpleJSAP
A simple interface to JSAP
that handles directly help,
explanation and an array of parameters.
More precisely, instances of this class behave exactly like those of
JSAP
, but additionally require a command name, an explanation
(a wordy description) and an array of parameters (which will be registered automatically).
A switch activated by --help is always
registered under the ID help.
A message will be automatically printed upon invocation
of the parse()
methods if an error occurs, or if the help switch is detected. In this
case, messagePrinted()
will return true, and the caller may check this condition
to stop its actions.
The screen width used to format the help text may be set using setScreenWidth(int)
.
The formatter will preserve newlines.
Note: as of 2.0a non-breaking spaces are temporarily disabled until some console encoding
issues have been worked out. - ML
Field Summary |
Fields inherited from class com.martiansoftware.jsap.JSAP |
BIGDECIMAL_PARSER, BIGINTEGER_PARSER, BOOLEAN_PARSER, BYTE_PARSER, CHARACTER_PARSER, CLASS_PARSER, COLOR_PARSER, DEFAULT_LISTSEPARATOR, DEFAULT_PARAM_HELP_SEPARATOR, DEFAULT_SCREENWIDTH, DOUBLE_PARSER, FLOAT_PARSER, GREEDY, INETADDRESS_PARSER, INTEGER_PARSER, INTSIZE_PARSER, LIST, LONG_PARSER, LONGSIZE_PARSER, MULTIPLEDECLARATIONS, NO_DEFAULT, NO_HELP, NO_LONGFLAG, NO_MULTIPLEDECLARATIONS, NO_SHORTFLAG, NOT_GREEDY, NOT_LIST, NOT_REQUIRED, PACKAGE_PARSER, REQUIRED, SHORT_PARSER, STRING_PARSER, URL_PARSER |
Constructor Summary | |
SimpleJSAP(String name)
Creates a new simple JSAP with a help switch, no explanation and default screen width. |
|
SimpleJSAP(String name,
String explanation)
Creates a new simple JSAP with default screen width. |
|
SimpleJSAP(String name,
String explanation,
Parameter[] parameter)
Creates a new simple JSAP with default screen width. |
Method Summary | |
int |
getScreenWidth()
Returns the current screen width. |
boolean |
messagePrinted()
Returns true if the last parsing caused the a message to be printed. |
JSAPResult |
parse(String arg)
Parses the specified command line. |
JSAPResult |
parse(String[] arg)
Parses the specified command line array. |
SimpleJSAP |
setScreenWidth(int screenWidth)
Sets the screen width. |
Methods inherited from class com.martiansoftware.jsap.JSAP |
finalize, getByID, getByLongFlag, getByShortFlag, getByShortFlag, getHelp, getHelp, getHelp, getIDMap, getUnflaggedOptionsIterator, getUsage, registerDefaultSource, registerParameter, setHelp, setUsage, toString, unregisterDefaultSource, unregisterParameter |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SimpleJSAP(String name, String explanation, Parameter[] parameter) throws JSAPException
name
- the name of the command for which help will be printed.explanation
- a wordy explanation of the command, or null
for no explanation.parameter
- an array of parameters, which will be registered for you, or null
.public SimpleJSAP(String name, String explanation) throws JSAPException
name
- the name of the command for which help will be printed.explanation
- a wordy explanation of the command, or null
for no explanation.public SimpleJSAP(String name) throws JSAPException
name
- the name of the command for which help will be printed.Method Detail |
public JSAPResult parse(String arg)
JSAP
parse
in class JSAP
arg
- An array of command line arguments to parse. This array
is typically provided in the application's main class' main() method.
public JSAPResult parse(String[] arg)
JSAP
parse
in class JSAP
arg
- An array of command line arguments to parse. This array is
typically provided in the application's main class' main() method.
public int getScreenWidth()
This value will be passed to JSAP.getHelp(int)
, and used
to format the explanation.
public SimpleJSAP setScreenWidth(int screenWidth)
screenWidth
- the new screen width.
public boolean messagePrinted()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |