|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.cli2.option.OptionImpl
org.apache.commons.cli2.option.ArgumentImpl
public class ArgumentImpl
An implementation of an Argument.
Field Summary | |
---|---|
private java.lang.String |
consumeRemaining
|
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. |
private java.util.List |
defaultValues
|
private java.lang.String |
description
|
private char |
initialSeparator
|
private int |
maximum
|
private int |
minimum
|
private java.lang.String |
name
|
private static char |
NUL
|
private ResourceHelper |
resources
|
private char |
subsequentSeparator
|
private boolean |
subsequentSplit
|
private Validator |
validator
|
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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 arg)
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()
|
java.util.List |
getDefaultValues()
|
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()
|
java.util.Set |
getTriggers()
Identifies the argument prefixes that should trigger this option. |
Validator |
getValidator()
|
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 this option is required to be present. |
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)
Checks that the supplied CommandLine is valid with respect to this option. |
void |
validate(WriteableCommandLine commandLine,
Option option)
Performs any necessary validation on the values added to the CommandLine. |
Methods inherited from class org.apache.commons.cli2.option.OptionImpl |
---|
canProcess, checkPrefixes, equals, findOption, getId, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.commons.cli2.Option |
---|
canProcess, findOption, getId |
Field Detail |
---|
private static final char NUL
public static final char DEFAULT_INITIAL_SEPARATOR
public static final char DEFAULT_SUBSEQUENT_SEPARATOR
public static final java.lang.String DEFAULT_CONSUME_REMAINING
private final java.lang.String name
private final java.lang.String description
private final int minimum
private final int maximum
private final char initialSeparator
private final char subsequentSeparator
private final boolean subsequentSplit
private final Validator validator
private final java.lang.String consumeRemaining
private final java.util.List defaultValues
private final ResourceHelper resources
Constructor Detail |
---|
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
- The object responsible for validating the valuesconsumeRemaining
- The String used for the "consuming option" groupvalueDefaults
- The values to be used if none are specified.id
- The id of the option, 0 implies automatic assignment.OptionImpl.OptionImpl(int,boolean)
Method Detail |
---|
public java.lang.String getPreferredName()
Option
getPreferredName
in interface Option
public void processValues(WriteableCommandLine commandLine, java.util.ListIterator arguments, Option option) throws OptionException
Argument
processValues
in interface Argument
commandLine
- 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 arg)
Option
canProcess
in interface Option
arg
- The argument to be tested
public java.util.Set getPrefixes()
Option
getPrefixes
in interface Option
public void process(WriteableCommandLine commandLine, java.util.ListIterator args) throws OptionException
Option
process
in interface Option
commandLine
- The CommandLine object to store results inargs
- The arguments to process
OptionException
- if any problems occurpublic char getInitialSeparator()
Argument
getInitialSeparator
in interface Argument
public char getSubsequentSeparator()
public java.util.Set getTriggers()
Option
getTriggers
in interface Option
public java.lang.String getConsumeRemaining()
public java.util.List getDefaultValues()
public Validator getValidator()
public void validate(WriteableCommandLine commandLine) throws OptionException
Option
validate
in interface Option
commandLine
- The CommandLine to check.
OptionException
- if the CommandLine is not valid.public void validate(WriteableCommandLine commandLine, Option option) throws OptionException
Argument
validate
in interface Argument
commandLine
- 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)
Option
appendUsage
in interface Option
buffer
- the buffer to append tohelpSettings
- a set of display settings @see DisplaySettingcomp
- a comparator used to sort the Optionspublic java.lang.String getDescription()
Option
getDescription
in interface Option
HelpFormatter
public java.util.List helpLines(int depth, java.util.Set helpSettings, java.util.Comparator comp)
Option
helpLines
in interface Option
depth
- the initial indent depthhelpSettings
- the HelpSettings that should be appliedcomp
- a comparator used to sort options when applicable.
HelpLine
,
HelpFormatter
public int getMaximum()
Argument
getMaximum
in interface Argument
public int getMinimum()
Argument
getMinimum
in interface Argument
public java.lang.String stripBoundaryQuotes(java.lang.String token)
token
- the token to strip leading and trailing quotes
public boolean isRequired()
Option
isRequired
in interface Argument
isRequired
in interface Option
isRequired
in class OptionImpl
Argument.getMinimum()
,
Argument.getMaximum()
public void defaults(WriteableCommandLine commandLine)
Option
defaults
in interface Option
defaults
in class OptionImpl
commandLine
- The CommandLine object to store defaults inpublic void defaultValues(WriteableCommandLine commandLine, Option option)
Argument
defaultValues
in interface Argument
commandLine
- The CommandLine object to store defaults in.option
- The Option to store the defaults against.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |