@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 |
addLongIdentifier(java.lang.String s,
boolean isHidden)
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.
|
void |
addShortIdentifier(java.lang.Character c,
boolean isHidden)
Adds the provided character to the set of short identifiers for this
argument.
|
protected abstract void |
addToCommandLine(java.util.List<java.lang.String> argStrings)
Updates the provided list to add any strings that should be included on the
command line in order to represent this argument's current state.
|
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. |
java.lang.String |
getArgumentGroupName()
Retrieves the name of the argument group to which this argument belongs.
|
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 all long identifiers, including hidden identifiers,
for this argument.
|
java.util.List<java.lang.String> |
getLongIdentifiers(boolean includeHidden)
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 all short identifiers, including hidden identifiers,
for this argument.
|
java.util.List<java.lang.Character> |
getShortIdentifiers(boolean includeHidden)
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.
|
abstract java.util.List<java.lang.String> |
getValueStringRepresentations(boolean useDefault)
Retrieves a list containing the string representations of the values for
this argument, if any.
|
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 |
isSensitive()
Indicates whether values of this argument are considered sensitive.
|
boolean |
isUsageArgument()
Indicates whether this argument is intended to be used to trigger the
display of usage information.
|
protected void |
reset()
Resets this argument so that it appears in the same form as before it was
used to parse arguments.
|
void |
setArgumentGroupName(java.lang.String argumentGroupName)
Sets the name of the argument group to which this argument belongs.
|
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 |
setSensitive(boolean isSensitive)
Specifies whether values of this argument are considered sensitive.
|
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(@Nullable java.lang.Character shortIdentifier, @Nullable java.lang.String longIdentifier, boolean isRequired, int maxOccurrences, @Nullable java.lang.String valuePlaceholder, @NotNull 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.@Nullable public final java.lang.Character getShortIdentifier()
null
if none is
defined.@NotNull public final java.util.List<java.lang.Character> getShortIdentifiers()
@NotNull public final java.util.List<java.lang.Character> getShortIdentifiers(boolean includeHidden)
includeHidden
- Indicates whether to include hidden identifiers in
the list that is returned.public final void addShortIdentifier(@NotNull 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 void addShortIdentifier(@NotNull java.lang.Character c, boolean isHidden) throws ArgumentException
c
- The character to add to the set of short identifiers for
this argument. It must not be null
.isHidden
- Indicates whether the provided identifier should be
hidden. If this is true
, then the identifier can
be used to target this argument on the command line, but
it will not be included in usage information.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.@Nullable public final java.lang.String getLongIdentifier()
null
if none is
defined.@NotNull public final java.util.List<java.lang.String> getLongIdentifiers()
@NotNull public final java.util.List<java.lang.String> getLongIdentifiers(boolean includeHidden)
includeHidden
- Indicates whether to include hidden identifiers in
the list that is returned.public final void addLongIdentifier(@NotNull 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 void addLongIdentifier(@NotNull java.lang.String s, boolean isHidden) throws ArgumentException
s
- The string to add to the set of short identifiers for
this argument. It must not be null
.isHidden
- Indicates whether the provided identifier should be
hidden. If this is true
, then the identifier can
be used to target this argument on the command line, but
it will not be included in usage information.ArgumentException
- If this argument is already registered with the
argument parser.@NotNull 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.@Nullable public final java.lang.String getValuePlaceholder()
null
if
it does not take a value.@NotNull public abstract java.util.List<java.lang.String> getValueStringRepresentations(boolean useDefault)
useDefault
- Indicates whether to use any configured default value
if the argument doesn't have a user-specified value.@NotNull public final java.lang.String getDescription()
@Nullable public final java.lang.String getArgumentGroupName()
null
if this argument has not been assigned to any group.public final void setArgumentGroupName(@Nullable java.lang.String argumentGroupName)
argumentGroupName
- The argument group name for this argument. It
may be null
if this argument should not
be assigned to any particular group.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(@NotNull 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 final boolean isSensitive()
true
if values of this argument are considered sensitive,
or false
if not.public final void setSensitive(boolean isSensitive)
isSensitive
- Indicates whether values of this argument are
considered sensitive.@NotNull public abstract java.lang.String getDataTypeName()
@Nullable public java.lang.String getValueConstraints()
null
if there are none.protected void reset()
super.reset()
to ensure that all necessary reset processing is
performed.@NotNull public abstract Argument getCleanCopy()
protected abstract void addToCommandLine(@NotNull java.util.List<java.lang.String> argStrings)
argStrings
- The list to update with the string representation of
the command-line arguments.@NotNull public final java.lang.String toString()
toString
in class java.lang.Object
public abstract void toString(@NotNull java.lang.StringBuilder buffer)
buffer
- The buffer to which the information should be appended.protected void appendBasicToStringInfo(@NotNull java.lang.StringBuilder buffer)
toString
method.buffer
- The buffer to which information should be appended.