public class ArgumentImpl extends OptionImpl implements Argument
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_CONSUME_REMAINING
The default token to indicate that remaining arguments should be consumed
as values.
|
static char |
DEFAULT_INITIAL_SEPARATOR
The default value for the initial separator char.
|
static char |
DEFAULT_SUBSEQUENT_SEPARATOR
The default value for the subsequent separator char.
|
| Constructor and Description |
|---|
ArgumentImpl(java.lang.String name,
java.lang.String description,
int minimum,
int maximum,
char initialSeparator,
char subsequentSeparator,
Validator validator,
java.lang.String consumeRemaining,
java.util.List valueDefaults,
int id)
Creates a new Argument instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendUsage(java.lang.StringBuffer buffer,
java.util.Set helpSettings,
java.util.Comparator comp)
Appends usage information to the specified StringBuffer
|
boolean |
canProcess(WriteableCommandLine commandLine,
java.lang.String argument)
Indicates whether this Option will be able to process the particular
argument.
|
void |
defaults(WriteableCommandLine commandLine)
Adds defaults to a CommandLine.
|
void |
defaultValues(WriteableCommandLine commandLine,
Option option)
Adds defaults to a CommandLine.
|
java.lang.String |
getConsumeRemaining()
Return the consume remaining flag.
|
java.util.List |
getDefaultValues()
Return the list of default values.
|
java.lang.String |
getDescription()
Returns a description of the option.
|
char |
getInitialSeparator()
Returns the initial separator character or
'\0' if no character has been set.
|
int |
getMaximum()
Retrieves the maximum number of values acceptable for a valid Argument
|
int |
getMinimum()
Retrieves the minimum number of values required for a valid Argument
|
java.lang.String |
getPreferredName()
The preferred name of an option is used for generating help and usage
information.
|
java.util.Set |
getPrefixes()
Identifies the argument prefixes that should be considered options.
|
char |
getSubsequentSeparator()
Returns the subsequent separator character.
|
java.util.Set |
getTriggers()
Identifies the argument prefixes that should trigger this option.
|
Validator |
getValidator()
Return the argument validator.
|
java.util.List |
helpLines(int depth,
java.util.Set helpSettings,
java.util.Comparator comp)
Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.
|
boolean |
isRequired()
Indicates whether argument values must be present for the CommandLine to
be valid.
|
void |
process(WriteableCommandLine commandLine,
java.util.ListIterator args)
Processes String arguments into a CommandLine.
|
void |
processValues(WriteableCommandLine commandLine,
java.util.ListIterator arguments,
Option option)
Processes the "README" style element of the argument.
|
java.lang.String |
stripBoundaryQuotes(java.lang.String token)
If there are any leading or trailing quotes remove them from the
specified token.
|
void |
validate(WriteableCommandLine commandLine)
Performs any necessary validation on the values added to the
CommandLine.
|
void |
validate(WriteableCommandLine commandLine,
Option option)
Performs any necessary validation on the values added to the
CommandLine.
|
canProcess, checkPrefixes, equals, findOption, getId, hashCode, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitcanProcess, findOption, getIdpublic static final char DEFAULT_INITIAL_SEPARATOR
public static final char DEFAULT_SUBSEQUENT_SEPARATOR
public static final java.lang.String DEFAULT_CONSUME_REMAINING
public ArgumentImpl(java.lang.String name, java.lang.String description, int minimum, int maximum, char initialSeparator, char subsequentSeparator, Validator validator, java.lang.String consumeRemaining, java.util.List valueDefaults, int id)
name - the name of the argumentdescription - a description of the argumentminimum - the minimum number of values needed to be validmaximum - the maximum number of values allowed to be validinitialSeparator - the char separating option from valuesubsequentSeparator - the char separating values from each othervalidator - object responsible for validating the valuesconsumeRemaining - String used for the "consuming option" groupvalueDefaults - values to be used if none are specified.id - the id of the option, 0 implies automatic assignment.OptionImpl.OptionImpl(int,boolean)public java.lang.String getPreferredName()
getPreferredName in interface Optionpublic void processValues(WriteableCommandLine commandLine, java.util.ListIterator arguments, Option option) throws OptionException
processValues in interface ArgumentcommandLine - The CommandLine object to store results in.arguments - The arguments to process.option - The option to register value against.OptionException - if any problems occur.WriteableCommandLine.addValue(Option,Object)public boolean canProcess(WriteableCommandLine commandLine, java.lang.String argument)
canProcess in interface OptioncommandLine - the CommandLine object to store defaults inargument - the argument to be testedpublic java.util.Set getPrefixes()
getPrefixes in interface Optionpublic void process(WriteableCommandLine commandLine, java.util.ListIterator args) throws OptionException
process in interface OptioncommandLine - the CommandLine object to store results inargs - the arguments to processOptionException - if any problems occurpublic char getInitialSeparator()
getInitialSeparator in interface Argumentpublic char getSubsequentSeparator()
public java.util.Set getTriggers()
getTriggers in interface Optionpublic java.lang.String getConsumeRemaining()
public java.util.List getDefaultValues()
public Validator getValidator()
public void validate(WriteableCommandLine commandLine) throws OptionException
validate in interface OptioncommandLine - The CommandLine object to query.OptionException - if any problems occur.CommandLine.getValues(Option)public void validate(WriteableCommandLine commandLine, Option option) throws OptionException
validate in interface ArgumentcommandLine - The CommandLine object to query.option - The option to lookup values with.OptionException - if any problems occur.CommandLine.getValues(Option)public void appendUsage(java.lang.StringBuffer buffer, java.util.Set helpSettings, java.util.Comparator comp)
appendUsage in interface Optionbuffer - the buffer to append tohelpSettings - a set of display settings @see DisplaySettingcomp - a comparator used to sort the Optionspublic java.lang.String getDescription()
getDescription in interface OptionHelpFormatterpublic java.util.List helpLines(int depth, java.util.Set helpSettings, java.util.Comparator comp)
helpLines in interface Optiondepth - the initial indent depthhelpSettings - the HelpSettings that should be appliedcomp - a comparator used to sort options when applicable.HelpLine,
HelpFormatterpublic int getMaximum()
getMaximum in interface Argumentpublic int getMinimum()
getMinimum in interface Argumentpublic java.lang.String stripBoundaryQuotes(java.lang.String token)
token - the token to strip leading and trailing quotespublic boolean isRequired()
isRequired in interface ArgumentisRequired in interface OptionisRequired in class OptionImplgetMinimum(),
getMaximum()public void defaults(WriteableCommandLine commandLine)
defaults in interface Optiondefaults in class OptionImplcommandLine - the CommandLine object to store defaults in.public void defaultValues(WriteableCommandLine commandLine, Option option)
defaultValues in interface ArgumentcommandLine - the CommandLine object to store defaults in.option - the Option to store the defaults against.