Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
net.dpml.cli.option.OptionImpl
net.dpml.cli.option.GroupImpl
Constructor Summary | |
|
Method Summary | |
void |
|
void |
|
boolean |
|
void |
|
Option |
|
List |
|
String |
|
int |
|
int |
|
List |
|
String |
|
Set |
|
Set |
|
List |
|
boolean |
|
void |
|
void |
|
Methods inherited from class net.dpml.cli.option.OptionImpl | |
canProcess , checkPrefixes , defaults , equals , findOption , getId , hashCode , isRequired , toString |
public GroupImpl(List options, String name, String description, int minimum, int maximum)
Creates a new GroupImpl using the specified parameters.
- Parameters:
options
- the Options and Arguments that make up the Groupname
- the name of this Group, or nulldescription
- a description of this Groupminimum
- the minimum number of Options for a valid CommandLinemaximum
- the maximum number of Options for a valid CommandLine
public void appendUsage(StringBuffer buffer, Set helpSettings, Comparator comp)
Appends usage information to the specified StringBuffer
- Specified by:
- appendUsage in interface Option
- Parameters:
buffer
- the buffer to append tohelpSettings
- a set of display settings @see DisplaySettingcomp
- a comparator used to sort the Options
public void appendUsage(StringBuffer buffer, Set helpSettings, Comparator comp, String separator)
Appends usage information to the specified StringBuffer
- Specified by:
- appendUsage in interface Group
- Parameters:
buffer
- the buffer to append tohelpSettings
- a set of display settings @see DisplaySettingcomp
- a comparator used to sort the Optionsseparator
- the String used to separate member Options
public boolean canProcess(WriteableCommandLine commandLine, String arg)
Indicates whether this Option will be able to process the particular argument.
- Specified by:
- canProcess in interface Option
- Parameters:
commandLine
- the CommandLine object to store defaults inarg
- the argument to be tested
- Returns:
- true if the argument can be processed by this Option
public void defaults(WriteableCommandLine commandLine)
Process defaults.
- Overrides:
- defaults in interface OptionImpl
- Parameters:
commandLine
- the commandline
public Option findOption(String trigger)
Recursively searches for an option with the supplied trigger.
- Specified by:
- findOption in interface Option
- Overrides:
- findOption in interface OptionImpl
- Parameters:
trigger
- the trigger to search for.
- Returns:
- the matching option or null.
public List getAnonymous()
Gets the m_anonymous Arguments of this Group.
- Returns:
- the Argument options of this Group
public String getDescription()
Returns a description of the option. This string is used to build help messages as in the HelpFormatter.
- Specified by:
- getDescription in interface Option
- Returns:
- a description of the option.
- See Also:
HelpFormatter
public int getMaximum()
Retrieves the maximum number of values acceptable for a valid Argument
- Specified by:
- getMaximum in interface Group
- Returns:
- the maximum number of values
public int getMinimum()
Retrieves the minimum number of values required for a valid Argument
- Specified by:
- getMinimum in interface Group
- Returns:
- the minimum number of values
public List getOptions()
Gets the member Options of thie Group. Note this does not include any Arguments
- Returns:
- only the non Argument Options of the Group
public String getPreferredName()
The preferred name of an option is used for generating help and usage information.
- Specified by:
- getPreferredName in interface Option
- Returns:
- The preferred name of the option
public Set getPrefixes()
Identifies the argument prefixes that should be considered options. This is used to identify whether a given string looks like an option or an argument value. Typically an option would return the set [--,-] while switches might offer [-,+]. The returned Set must not be null.
- Specified by:
- getPrefixes in interface Option
- Returns:
- The set of prefixes for this Option
public Set getTriggers()
Identifies the argument prefixes that should trigger this option. This is used to decide which of many Options should be tried when processing a given argument string. The returned Set must not be null.
- Specified by:
- getTriggers in interface Option
- Returns:
- The set of triggers for this Option
public List helpLines(int depth, Set helpSettings, Comparator comp)
Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.
- Parameters:
depth
- the initial indent depthhelpSettings
- the HelpSettings that should be appliedcomp
- a comparator used to sort options when applicable.
- Returns:
- a List of HelpLineImpl objects
- See Also:
HelpLine
,HelpFormatter
public boolean isRequired()
Indicates whether argument values must be present for the CommandLine to be valid.
- Specified by:
- isRequired in interface Group
- isRequired in interface Option
- Overrides:
- isRequired in interface OptionImpl
- Returns:
- true iff the CommandLine will be invalid without at least one value
- See Also:
getMinimum()
,getMaximum()
public void process(WriteableCommandLine commandLine, ListIterator arguments) throws OptionException
Processes String arguments into a CommandLine. The iterator will initially point at the first argument to be processed and at the end of the method should point to the first argument not processed. This method MUST process at least one argument from the ListIterator.
- Parameters:
commandLine
- the CommandLine object to store results inarguments
- the arguments to process
- Throws:
OptionException
- if any problems occur
public void validate(WriteableCommandLine commandLine) throws OptionException
Checks that the supplied CommandLine is valid with respect to this option.
- Parameters:
commandLine
- the CommandLine to check.
- Throws:
OptionException
- if the CommandLine is not valid.