@NotExtensible @Mutable @ThreadSafety(level=NOT_THREADSAFE) public abstract class Argument extends java.lang.Object implements java.io.Serializable
Modifier | Constructor and Description |
---|---|
protected |
Argument(Argument source)
Creates a new argument with the same generic information as the provided
argument.
|
protected |
Argument(java.lang.Character shortIdentifier,
java.lang.String longIdentifier,
boolean isRequired,
int maxOccurrences,
java.lang.String valuePlaceholder,
java.lang.String description)
Creates a new argument with the provided information.
|
Modifier and Type | Method and Description |
---|---|
void |
addLongIdentifier(java.lang.String s)
Adds the provided string to the set of short identifiers for this argument.
|
void |
addShortIdentifier(java.lang.Character c)
Adds the provided character to the set of short identifiers for this
argument.
|
protected abstract void |
addValue(java.lang.String valueString)
Adds the provided value to the set of values for this argument.
|
protected void |
appendBasicToStringInfo(java.lang.StringBuilder buffer)
Appends a basic set of information for this argument to the provided
buffer in a form suitable for use in the
toString method. |
abstract Argument |
getCleanCopy()
Creates a copy of this argument that is "clean" and appears as if it has
not been used in the course of parsing an argument set.
|
abstract java.lang.String |
getDataTypeName()
Retrieves a concise name of the data type with which this argument is
associated.
|
java.lang.String |
getDescription()
Retrieves the description for this argument.
|
java.lang.String |
getIdentifierString()
Retrieves a string that may be used to identify this argument.
|
java.lang.String |
getLongIdentifier()
Retrieves the long identifier for this argument.
|
java.util.List<java.lang.String> |
getLongIdentifiers()
Retrieves the list of long identifiers for this argument.
|
int |
getMaxOccurrences()
Retrieves the maximum number of times that this argument may be provided.
|
int |
getNumOccurrences()
Retrieves the number of times that this argument was included in the
provided set of command line arguments.
|
java.lang.Character |
getShortIdentifier()
Retrieves the short identifier for this argument.
|
java.util.List<java.lang.Character> |
getShortIdentifiers()
Retrieves the list of short identifiers for this argument.
|
java.lang.String |
getValueConstraints()
Retrieves a human-readable string with information about any constraints
that may be imposed for values of this argument.
|
java.lang.String |
getValuePlaceholder()
Retrieves the value placeholder string for this argument.
|
protected abstract boolean |
hasDefaultValue()
Indicates whether this argument has one or more default values that will be
used if it is not provided on the command line.
|
boolean |
hasLongIdentifier()
Indicates whether this argument has a long identifier.
|
boolean |
hasShortIdentifier()
Indicates whether this argument has a short identifier.
|
boolean |
isHidden()
Indicates whether this argument should be excluded from usage information.
|
boolean |
isPresent()
Indicates whether this argument was either included in the provided set of
command line arguments or has a default value that can be used instead.
|
boolean |
isRequired()
Indicates whether this argument is required to be provided.
|
boolean |
isUsageArgument()
Indicates whether this argument is intended to be used to trigger the
display of usage information.
|
void |
setHidden(boolean isHidden)
Specifies whether this argument should be excluded from usage information.
|
void |
setMaxOccurrences(int maxOccurrences)
Specifies the maximum number of times that this argument may be provided.
|
void |
setUsageArgument(boolean isUsageArgument)
Specifies whether this argument should be considered a usage argument.
|
boolean |
takesValue()
Indicates whether this argument takes a value.
|
java.lang.String |
toString()
Retrieves a string representation of this argument.
|
abstract void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this argument to the provided buffer.
|
protected Argument(java.lang.Character shortIdentifier, java.lang.String longIdentifier, boolean isRequired, int maxOccurrences, java.lang.String valuePlaceholder, java.lang.String description) throws ArgumentException
shortIdentifier
- The short identifier for this argument. It may
not be null
if the long identifier is
null
.longIdentifier
- The long identifier for this argument. It may
not be null
if the short identifier is
null
.isRequired
- Indicates whether this argument is required to
be provided.maxOccurrences
- The maximum number of times this argument may be
provided on the command line. A value less than
or equal to zero indicates that it may be present
any number of times.valuePlaceholder
- A placeholder to display in usage information to
indicate that a value must be provided. If this
is null
, then the argument will not be
allowed to take a value. If it is not
null
, then the argument will be required
to take a value.description
- A human-readable description for this argument.
It must not be null
.ArgumentException
- If there is a problem with the definition of
this argument.public final boolean hasShortIdentifier()
true
if it has a short identifier, or false
if
not.public final java.lang.Character getShortIdentifier()
null
if none is
defined.public final java.util.List<java.lang.Character> getShortIdentifiers()
public final void addShortIdentifier(java.lang.Character c) throws ArgumentException
c
- The character to add to the set of short identifiers for this
argument. It must not be null
.ArgumentException
- If this argument is already registered with the
argument parser.public final boolean hasLongIdentifier()
true
if it has a long identifier, or false
if
not.public final java.lang.String getLongIdentifier()
null
if none is
defined.public final java.util.List<java.lang.String> getLongIdentifiers()
public final void addLongIdentifier(java.lang.String s) throws ArgumentException
s
- The string to add to the set of short identifiers for this
argument. It must not be null
.ArgumentException
- If this argument is already registered with the
argument parser.public final java.lang.String getIdentifierString()
public final boolean isRequired()
true
if this argument is required to be provided, or
false
if not.public final int getMaxOccurrences()
public final void setMaxOccurrences(int maxOccurrences)
maxOccurrences
- The maximum number of times that this argument
may be provided. A value less than or equal to
zero indicates that there should be no limit on the
maximum number of occurrences.public boolean takesValue()
true
if this argument takes a value, or false
if
not.public final java.lang.String getValuePlaceholder()
null
if
it does not take a value.public final java.lang.String getDescription()
public final boolean isHidden()
true
if this argument should be excluded from usage
information, or false
if not.public final void setHidden(boolean isHidden)
isHidden
- Specifies whether this argument should be excluded from
usage information.public final boolean isUsageArgument()
true
if this argument is a usage argument, or
false
if not.public final void setUsageArgument(boolean isUsageArgument)
isUsageArgument
- Specifies whether this argument should be
considered a usage argument.public final boolean isPresent()
true
if this argument was included in the provided set of
command line arguments, or false
if not.public final int getNumOccurrences()
protected abstract void addValue(java.lang.String valueString) throws ArgumentException
valueString
- The string representation of the value.ArgumentException
- If the provided value is not acceptable, if
this argument does not accept values, or if
this argument already has the maximum allowed
number of values.protected abstract boolean hasDefaultValue()
true
if this argument has one or more default values, or
false
if not.public abstract java.lang.String getDataTypeName()
public java.lang.String getValueConstraints()
null
if there are none.public abstract Argument getCleanCopy()
public final java.lang.String toString()
toString
in class java.lang.Object
public abstract void toString(java.lang.StringBuilder buffer)
buffer
- The buffer to which the information should be appended.protected void appendBasicToStringInfo(java.lang.StringBuilder buffer)
toString
method.buffer
- The buffer to which information should be appended.