| |
|
| java.lang.Object com.Ostermiller.util.CmdLnOption
CmdLnOption | final public class CmdLnOption (Code) | | A command line option used by the CommandLineOptions parser.
More information about this class and code samples for suggested use are
available from ostermiller.org.
author: Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities since: ostermillerutils 1.07.00 |
Method Summary | |
public CmdLnOption | addLongName(String name) | public CmdLnOption | addLongNames(Collection<String> longNames) | public CmdLnOption | addLongNames(String[] longNames) | public CmdLnOption | addShortName(Character name) | public CmdLnOption | addShortNames(Collection<Character> shortNames) | public CmdLnOption | addShortNames(char[] shortNames) | public CmdLnOption | addShortNames(Character[] shortNames) | public String | getDescription() | String | getHelp(String longStart, String shortStart, int indent, int lineWidth) Get the help message for this option appropriate for inclusion in
"print help".
It will be formatted like this:
--option -o > description
Two spaces at the beginning, and at least two spaces after the option
specification before the description. | int | getHelpArgumentsLength(String longStart, String shortStart) Get the length of the argument specification portion of
the help message in characters. | CmdLnListener | getListener() | String | getLongName() | List<String> | getLongNames() | int | getMaxArguments() | int | getMinArguments() | Character | getShortName() | List<Character> | getShortNames() | public Object | getUserObject() An object that may be set by the user. | public CmdLnOption | setArgumentBounds(int minArguments, int maxArguments) Sets the bounds for command line arguments. | public CmdLnOption | setDescription(String description) | void | setImmutable() Called by the command line options parser
to set this option to not modifiable. | public CmdLnOption | setListener(CmdLnListener callback) | public CmdLnOption | setNoArguments() Sets the argument bounds to require no arguments
(zero arguments minimum, zero arguments maximum). | public CmdLnOption | setOptionalArgument() Sets the argument bounds for a single optional argument
(zero arguments minimum, one argument maximum). | public CmdLnOption | setRequiredArgument() Sets the argument bounds for a single required argument
(one argument minimum, one argument maximum). | public CmdLnOption | setUnlimitedArguments() Sets the argument bounds for unlimited (but optional) arguments
(zero arguments minimum, Integer.MAX_VALUE arguments maximum). | public CmdLnOption | setUserObject(Object userObject) An object that may be set by the user. | public String | toString() Get a short string description this option. |
CmdLnOption | public CmdLnOption(String[] longNames)(Code) | | Parameters: longNames - list long names for this option throws: IllegalArgumentException - if the the list does not contain at least one long name since: ostermillerutils 1.07.00 |
CmdLnOption | public CmdLnOption(char[] shortNames)(Code) | | Parameters: shortNames - list short names for this option throws: IllegalArgumentException - if the the list does not contain at least one short name since: ostermillerutils 1.07.00 |
CmdLnOption | public CmdLnOption(String longName)(Code) | | Parameters: longName - the long name for this option throws: IllegalArgumentException - if the name is null since: ostermillerutils 1.07.00 |
CmdLnOption | public CmdLnOption(Character shortName)(Code) | | Parameters: shortName - the short name for this option since: ostermillerutils 1.07.00 |
CmdLnOption | public CmdLnOption(String[] longNames, char[] shortNames)(Code) | | Parameters: longNames - list long names for this option Parameters: shortNames - list short names for this option throws: IllegalArgumentException - if the the lists do not contain at least one name since: ostermillerutils 1.07.00 |
CmdLnOption | public CmdLnOption(String longName, Character shortName)(Code) | | Parameters: longName - the long name for this option Parameters: shortName - the short name for this option since: ostermillerutils 1.07.00 |
addShortNames | public CmdLnOption addShortNames(char[] shortNames)(Code) | | Parameters: shortNames - short names to be added this for method chaining throws: IllegalArgumentException - if the name is null or blank since: ostermillerutils 1.07.00 |
getDescription | public String getDescription()(Code) | | the description used in the help message or null ifno description has been set. since: ostermillerutils 1.07.00 |
getHelp | String getHelp(String longStart, String shortStart, int indent, int lineWidth)(Code) | | Get the help message for this option appropriate for inclusion in
"print help".
It will be formatted like this:
--option -o > description
Two spaces at the beginning, and at least two spaces after the option
specification before the description. If the indent is large,
there may be more spaces before the description.
If it is longer that the line width and must wrap, the description will
continue on the next line which will start with eight spaces.
Parameters: longStart - What long options start with (typically "--") Parameters: shortStart - What short options start with (typically "-") Parameters: indent - Minimum character count at which to start the description after specifying the option Parameters: lineWidth - Character count at which to wrap (if possible) help message since: ostermillerutils 1.07.00 |
getHelpArgumentsLength | int getHelpArgumentsLength(String longStart, String shortStart)(Code) | | Get the length of the argument specification portion of
the help message in characters. Does not include any space
between the specification and the description.
Parameters: longStart - What long options start with (typically "--") Parameters: shortStart - What short options start with (typically "-") number of characters in the argument specification since: ostermillerutils 1.07.00 |
getListener | CmdLnListener getListener()(Code) | | Get the call back object
the call back object since: ostermillerutils 1.07.00 |
getLongName | String getLongName()(Code) | | Get the first long name or null if no long names
long name since: ostermillerutils 1.07.00 |
getLongNames | List<String> getLongNames()(Code) | | Get the entire list of long names
unmodifiable list of long names |
getMaxArguments | int getMaxArguments()(Code) | | the maximum number of arguments allowed since: ostermillerutils 1.07.00 |
getMinArguments | int getMinArguments()(Code) | | the minimum number of arguments allowed since: ostermillerutils 1.07.00 |
getShortName | Character getShortName()(Code) | | Get the first short name or null if no short names
short name since: ostermillerutils 1.07.00 |
getShortNames | List<Character> getShortNames()(Code) | | Get the entire list of short names
unmodifiable list of short names since: ostermillerutils 1.07.00 |
getUserObject | public Object getUserObject()(Code) | | An object that may be set by the user.
Suggested use: set the user object to an enum
value that can be used in a switch statement.
since: ostermillerutils 1.07.00 the userObject |
setArgumentBounds | public CmdLnOption setArgumentBounds(int minArguments, int maxArguments)(Code) | | Sets the bounds for command line arguments.
Parameters: minArguments - the minimum number of arguments this command line option should expect Parameters: maxArguments - the maximum number of arguments this command line option will accept throws: IllegalArgumentException - if minimum arguments is negative throws: IllegalArgumentException - if maximum arguments is less than minimum arguments throws: IllegalStateException - if this argument has already been used in parsing CommandLineOptions this command line option for method chaining since: ostermillerutils 1.07.00 |
setDescription | public CmdLnOption setDescription(String description)(Code) | | Parameters: description - the description used in the help message this for method chaining since: ostermillerutils 1.07.00 |
setImmutable | void setImmutable()(Code) | | Called by the command line options parser
to set this option to not modifiable.
since: ostermillerutils 1.07.00 |
setListener | public CmdLnOption setListener(CmdLnListener callback)(Code) | | Set the call back object
Parameters: callback - the call back object this for method chaining since: ostermillerutils 1.07.00 |
setNoArguments | public CmdLnOption setNoArguments()(Code) | | Sets the argument bounds to require no arguments
(zero arguments minimum, zero arguments maximum).
This is the default state for a new command line option.
throws: IllegalStateException - if this argument has already been used in parsing CommandLineOptions this command line option for method chaining since: ostermillerutils 1.07.00 |
setOptionalArgument | public CmdLnOption setOptionalArgument()(Code) | | Sets the argument bounds for a single optional argument
(zero arguments minimum, one argument maximum).
throws: IllegalStateException - if this argument has already been used in parsing CommandLineOptions this command line option for method chaining since: ostermillerutils 1.07.00 |
setRequiredArgument | public CmdLnOption setRequiredArgument()(Code) | | Sets the argument bounds for a single required argument
(one argument minimum, one argument maximum).
throws: IllegalStateException - if this argument has already been used in parsing CommandLineOptions this command line option for method chaining since: ostermillerutils 1.07.00 |
setUnlimitedArguments | public CmdLnOption setUnlimitedArguments()(Code) | | Sets the argument bounds for unlimited (but optional) arguments
(zero arguments minimum, Integer.MAX_VALUE arguments maximum).
throws: IllegalStateException - if this argument has already been used in parsing CommandLineOptions this command line option for method chaining |
setUserObject | public CmdLnOption setUserObject(Object userObject)(Code) | | An object that may be set by the user.
Suggested use: set the user object to an enum
value that can be used in a switch statement.
Parameters: userObject - the userObject to set this for method chaining since: ostermillerutils 1.07.00 |
toString | public String toString()(Code) | | Get a short string description this option.
It will be either the long name (if it has one)
or the short name if it does not have a long name
string representation since: ostermillerutils 1.07.00 |
|
|
|