net.dpml.cli.option
Class DefaultOption
- Option, Parent
A Parent implementation representing normal options.
DefaultOption(String shortPrefix, String longPrefix, boolean burstEnabled, String preferredName, String description, Set aliases, Set burstAliases, boolean required, Argument argument, Group children, int id) - Creates a new DefaultOption
|
void | appendUsage(StringBuffer buffer, Set helpSettings, Comparator comp) - Appends usage information to the specified StringBuffer
|
boolean | canProcess(WriteableCommandLine commandLine, String argument) - Indicates whether this Option will be able to process the particular
argument.
|
String | getPreferredName() - The preferred name of an option is used for generating help and usage
information.
|
Set | getPrefixes() - Identifies the argument prefixes that should be considered options.
|
Set | getTriggers() - Identifies the argument prefixes that should trigger this option.
|
void | processParent(WriteableCommandLine commandLine, ListIterator arguments) - Process the parent.
|
void | validate(WriteableCommandLine commandLine) - Checks that the supplied CommandLine is valid with respect to this
option.
|
appendUsage , canProcess , defaults , findOption , getArgument , getChildren , getDescription , getPrefixes , helpLines , process , validate |
DEFAULT_BURST_ENABLED
public static final boolean DEFAULT_BURST_ENABLED
The default value for the burstEnabled constructor parameter
DEFAULT_LONG_PREFIX
public static final String DEFAULT_LONG_PREFIX
The default token used to prefix a long option
DEFAULT_SHORT_PREFIX
public static final String DEFAULT_SHORT_PREFIX
The default token used to prefix a short option
DefaultOption
public DefaultOption(String shortPrefix,
String longPrefix,
boolean burstEnabled,
String preferredName,
String description,
Set aliases,
Set burstAliases,
boolean required,
Argument argument,
Group children,
int id)
throws IllegalArgumentException
Creates a new DefaultOption
shortPrefix
- the prefix used for short optionslongPrefix
- the prefix used for long optionsburstEnabled
- should option bursting be enabledpreferredName
- the preferred name for this Option, this should
begin with either shortPrefix or longPrefixdescription
- a description of this Optionaliases
- the alternative names for this OptionburstAliases
- the aliases that can be burstrequired
- whether the Option is strictly requiredargument
- the Argument belonging to this Parent, or nullchildren
- the Group children belonging to this Parent, ot nullid
- the unique identifier for this Option
appendUsage
public void appendUsage(StringBuffer buffer,
Set helpSettings,
Comparator comp)
Appends usage information to the specified StringBuffer
- appendUsage in interface Option
- appendUsage in interface ParentImpl
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 argument)
Indicates whether this Option will be able to process the particular
argument.
- canProcess in interface Option
- canProcess in interface ParentImpl
commandLine
- the CommandLine object to store defaults inargument
- the argument to be tested
- true if the argument can be processed by this Option
getPreferredName
public String getPreferredName()
The preferred name of an option is used for generating help and usage
information.
- getPreferredName in interface Option
- The preferred name 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
- getPrefixes in interface ParentImpl
- The set of prefixes for this Option
getTriggers
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.
- getTriggers in interface Option
- The set of triggers for this Option