|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.freehep.util.commandline.CommandLine
CommandLine parses a command line for parameters and options.
Nested Class Summary | |
static class |
CommandLine.Option
Keeps option names and types. |
static class |
CommandLine.Parameter
Keeps mandatory and optional parameter names. |
Constructor Summary | |
CommandLine(String name,
String description,
int numberOfParameters)
Creates a CommandLine object to be used for parsing a set of arguments |
|
CommandLine(String name,
String description,
int numberOfParameters,
boolean multiLevel)
Creates a CommandLine object to be used for parsing a set of arguments |
Method Summary | |
void |
addBailOutOption(String longName,
String shortName,
String comment)
Adds an option to be recognized by parse, without doing parameter or option checking. |
void |
addMultiOption(String name,
String valueDescription,
String comment)
Adds an option to be recognized by parse. |
void |
addOption(String longName,
String shortName,
String comment)
Adds an option to be recognized by parse. |
void |
addOption(String longName,
String shortName,
String[] qualifiers,
String comment)
Adds an option to be recognized by parse. |
void |
addOption(String longName,
String shortName,
String valueDescription,
String comment)
Adds an option to be recognized by parse. |
void |
addParameter(String name,
String comment)
Adds a parameter to be recognized by parse. |
void |
enableChecking(boolean check)
enables checking of the options and parameters |
String |
getArgument(String name)
|
String[] |
getArguments()
|
String |
getDescription()
|
CommandLineException |
getException()
|
String |
getHelp()
Get the help message, suitable for printing in response to a -help option |
Vector |
getMultiOption(String name)
|
String |
getName()
|
String |
getOption(String name)
|
String |
getOption(String name,
String defaultValue)
|
Enumeration |
getOptions()
|
Enumeration |
getParameters()
|
String[] |
getUnparsedArguments()
|
boolean |
hasOption(String name)
|
boolean |
isLegalOption(String name)
|
boolean |
parse(String[] args)
Parses the supplied arguments. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public CommandLine(String name, String description, int numberOfParameters, boolean multiLevel)
name
- name of the commanddescription
- description of the commandnumberOfParameters
- minumum number of parametersmultiLevel
- forces the command line to be multi-level (i.e. does not check for
max number of parameterspublic CommandLine(String name, String description, int numberOfParameters)
name
- name of the commanddescription
- description of the commandnumberOfParameters
- minumum number of parametersMethod Detail |
public void enableChecking(boolean check)
check
- sets checkingpublic void addOption(String longName, String shortName, String comment)
longName
- the full name of the optionshortName
- the short name of the option (may be set to null)comment
- description of the arguments to the optionpublic void addOption(String longName, String shortName, String[] qualifiers, String comment)
longName
- the full name of the optionshortName
- the short name of the option (may be set to null)qualifiers
- gives a list of qualifiers you can usecomment
- description of the arguments to the optionpublic void addOption(String longName, String shortName, String valueDescription, String comment)
longName
- the full name of the optionshortName
- the short name of the option (may be set to null)valueDescription
- description of the valuecomment
- description of the arguments to the optionpublic void addBailOutOption(String longName, String shortName, String comment)
longName
- the full name of the optionshortName
- the short name of the option (may be set to null)comment
- description of the arguments to the optionpublic void addMultiOption(String name, String valueDescription, String comment)
name
- the full name of the option (preferably one character)valueDescription
- what the value after the option meanscomment
- description of the argument to the optionpublic void addParameter(String name, String comment)
name
- name of the parametercomment
- comment describing the parameterpublic String getName()
public String getDescription()
public Enumeration getOptions()
public Enumeration getParameters()
public boolean isLegalOption(String name)
public boolean parse(String[] args) throws CommandLineException
args
- arguments for the command, including all options
CommandLineException
- in case the parsing failed.public CommandLineException getException()
public String toString()
public String getOption(String name)
name
- name of the option
public Vector getMultiOption(String name)
name
- name of the option
public String getOption(String name, String defaultValue)
name
- name of the optiondefaultValue
- default value if option was not set
public boolean hasOption(String name)
name
- name of the option
public String getArgument(String name)
name
- name of the argument
public String[] getArguments()
public String[] getUnparsedArguments()
public String getHelp()
|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |