net.dpml.cli.option
Class ParentImpl
- Option, Parent
A base implementation of Parent providing limited ground work for further
Parent implementations.
ParentImpl(Argument argument, Group children, String description, int id, boolean required) - Creation of a new ParaentImpl.
|
void | appendUsage(StringBuffer buffer, Set helpSettings, Comparator comp) - Appends usage information to the specified StringBuffer
|
boolean | canProcess(WriteableCommandLine commandLine, String arg) - Indicates whether this Option will be able to process the particular
argument.
|
void | defaults(WriteableCommandLine commandLine) - Adds defaults to a CommandLine.
|
Option | findOption(String trigger) - Recursively searches for an option with the supplied trigger.
|
Argument | getArgument() - Return the argument value if any.
|
Group | getChildren() - Return any children.
|
String | getDescription() - Returns a description of the option.
|
Set | getPrefixes() - Identifies the argument prefixes that should be considered options.
|
List | helpLines(int depth, Set helpSettings, Comparator comp) - Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.
|
void | process(WriteableCommandLine commandLine, ListIterator arguments) - Processes String arguments into a CommandLine.
|
void | validate(WriteableCommandLine commandLine) - Checks that the supplied CommandLine is valid with respect to this
option.
|
ParentImpl
protected ParentImpl(Argument argument,
Group children,
String description,
int id,
boolean required)
Creation of a new ParaentImpl.
argument
- an argumentchildren
- the childrendescription
- the descriptionid
- the idrequired
- the required flag
appendUsage
public void appendUsage(StringBuffer buffer,
Set helpSettings,
Comparator comp)
Appends usage information to the specified StringBuffer
- appendUsage in interface Option
buffer
- the buffer to append tohelpSettings
- a set of display settings @see DisplaySettingcomp
- a comparator used to sort the Options
canProcess
public boolean canProcess(WriteableCommandLine commandLine,
String arg)
Indicates whether this Option will be able to process the particular
argument.
- canProcess in interface Option
commandLine
- the CommandLine object to store defaults inarg
- the argument to be tested
- true if the argument can be processed by this Option
defaults
public void defaults(WriteableCommandLine commandLine)
Adds defaults to a CommandLine.
Any defaults for this option are applied as well as the defaults for
any contained options
- defaults in interface Option
- defaults in interface OptionImpl
commandLine
- the CommandLine object to store defaults in
getDescription
public String getDescription()
Returns a description of the option. This string is used to build help
messages as in the HelpFormatter.
- getDescription in interface Option
- a description of the option.
getPrefixes
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.
- getPrefixes in interface Option
- The set of prefixes for this Option
helpLines
public List helpLines(int depth,
Set helpSettings,
Comparator comp)
Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.
- helpLines in interface Option
depth
- the initial indent depthhelpSettings
- the HelpSettings that should be appliedcomp
- a comparator used to sort options when applicable.
- a List of HelpLineImpl objects
process
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.
- process in interface Option
commandLine
- the CommandLine object to store results inarguments
- the arguments to process