|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unboundid.util.args.Argument
@NotExtensible @Mutable @ThreadSafety(level=NOT_THREADSAFE) public abstract class Argument
This class defines a generic command line argument, which provides functionality applicable to all argument types. Subclasses may enforce additional constraints or provide additional functionality.
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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 |
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 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. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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.protected Argument(Argument source)
source
- The argument to use as the source for this argument.Method Detail |
---|
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 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.
public final java.lang.String getDescription()
public final java.lang.String getArgumentGroupName()
null
if this argument has not been assigned to any group.public final void setArgumentGroupName(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(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.public abstract java.lang.String getDataTypeName()
public java.lang.String getValueConstraints()
null
if there are none.protected void reset()
super.reset()
to ensure that all necessary reset processing is
performed.
public abstract Argument getCleanCopy()
protected abstract void addToCommandLine(java.util.List<java.lang.String> argStrings)
argStrings
- The list to update with the string representation of
the command-line arguments.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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |