|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opends.server.util.args.Argument
public abstract class Argument
This class defines a generic argument that may be used in the argument list for an application. This is an abstract class that must be subclassed in order to provide specific functionality.
Constructor Summary | |
---|---|
protected |
Argument(java.lang.String name,
java.lang.Character shortIdentifier,
java.lang.String longIdentifier,
boolean isRequired,
boolean isMultiValued,
boolean needsValue,
Message valuePlaceholder,
java.lang.String defaultValue,
java.lang.String propertyName,
Message description)
Creates a new argument with the provided information. |
Method Summary | |
---|---|
void |
addValue(java.lang.String valueString)
Adds a value to the set of values for this argument. |
void |
clearValues()
Clears the set of values assigned to this argument. |
boolean |
getBooleanValue()
Retrieves the value of this argument as a Boolean . |
java.lang.String |
getDefaultValue()
Retrieves the default value that will be used for this argument if it is not specified on the command line and it is not set from a properties file. |
Message |
getDescription()
Retrieves the human-readable description for this argument. |
int |
getIntValue()
Retrieves the value of this argument as an integer. |
java.util.LinkedList<java.lang.Integer> |
getIntValues()
Retrieves the set of values for this argument as a list of integers. |
java.lang.String |
getLongIdentifier()
Retrieves the long (multi-character) identifier that may be used to specify the value of this argument. |
java.lang.String |
getName()
Retrieves the generic name that will be used to refer to this argument. |
java.lang.String |
getPropertyName()
Retrieves the name of a property in a properties file that may be used to set the default value for this argument if it is present. |
java.lang.Character |
getShortIdentifier()
Retrieves the single-character identifier that may be used to specify the value of this argument. |
java.lang.String |
getValue()
Retrieves the string vale for this argument. |
Message |
getValuePlaceholder()
Retrieves the value placeholder that will be displayed for this argument in the generated usage information. |
java.util.LinkedList<java.lang.String> |
getValues()
Retrieves the set of string values for this argument. |
boolean |
hasValue()
Indicates whether this argument has at least one value. |
boolean |
isHidden()
Indicates whether this argument should be hidden from the usage information. |
boolean |
isMultiValued()
Indicates whether this argument may be provided more than once on the command line to specify multiple values. |
boolean |
isPresent()
Indicates whether this argument is present in the parsed set of command-line arguments. |
boolean |
isRequired()
Indicates whether this argument is required to have at least one value. |
boolean |
isValueSetByProperty()
Indicates whether this argument was provided in the set of properties found is a properties file. |
boolean |
needsValue()
Indicates whether a value must be provided with this argument if it is present. |
void |
setDefaultValue(java.lang.String defaultValue)
Specifies the default value that will be used for this argument if it is not specified on the command line and it is not set from a properties file. |
void |
setHidden(boolean isHidden)
Specifies whether this argument should be hidden from the usage information. |
void |
setMultiValued(boolean isMultiValued)
Specifies whether this argument may be provided more than once on the command line to specify multiple values. |
void |
setNeedsValue(boolean needsValue)
Specifies whether a value must be provided with this argument if it is present. |
void |
setPresent(boolean isPresent)
Specifies whether this argument is present in the parsed set of command-line arguments. |
void |
setPropertyName(java.lang.String propertyName)
Specifies the name of a property in a properties file that may be used to set the default value for this argument if it is present. |
void |
setRequired(boolean isRequired)
Specifies whether this argument is required to have at least one value. |
void |
setValuePlaceholder(Message valuePlaceholder)
Specifies the value placeholder that will be displayed for this argument in the generated usage information. |
void |
setValueSetByProperty(boolean isValueSetByProperty)
Specifies whether this argument was provided in the set of properties found is a properties file. |
abstract boolean |
valueIsAcceptable(java.lang.String valueString,
MessageBuilder invalidReason)
Indicates whether the provided value is acceptable for use in this argument. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Argument(java.lang.String name, java.lang.Character shortIdentifier, java.lang.String longIdentifier, boolean isRequired, boolean isMultiValued, boolean needsValue, Message valuePlaceholder, java.lang.String defaultValue, java.lang.String propertyName, Message description) throws ArgumentException
name
- The generic name that should be used to refer to
this argument.shortIdentifier
- The single-character identifier for this
argument, or null
if there is none.longIdentifier
- The long identifier for this argument, or
null
if there is none.isRequired
- Indicates whether this argument must be specified
on the command line.isMultiValued
- Indicates whether this argument may be specified
more than once to provide multiple values.needsValue
- Indicates whether this argument requires a value.valuePlaceholder
- The placeholder for the argument value that will
be displayed in usage information, or
null
if this argument does not
require a value.defaultValue
- The default value that should be used for this
argument if none is provided in a properties file
or on the command line. This may be
null
if there is no generic default.propertyName
- The name of the property in a property file that
may be used to override the default value but
will be overridden by a command-line argument.description
- Message for the description of this
argument.
ArgumentException
- If there is a problem with any of the
parameters used to create this argument.Method Detail |
---|
public java.lang.String getName()
public java.lang.Character getShortIdentifier()
null
if there is none.public java.lang.String getLongIdentifier()
public boolean isRequired()
true
if this argument is required to have at least
one value, or false
if it does not need to have a
value.public void setRequired(boolean isRequired)
isRequired
- Indicates whether this argument is required to have at
least one value.public boolean isPresent()
true
if this argument is present in the parsed set of
command-line arguments, or false
if not.public void setPresent(boolean isPresent)
isPresent
- Indicates whether this argument is present in the set of
command-line arguments.public boolean isHidden()
true
if this argument should be hidden from the usage
information, or false
if not.public void setHidden(boolean isHidden)
isHidden
- Indicates whether this argument should be hidden from the
usage information.public boolean isMultiValued()
true
if this argument may be provided more than once
on the command line to specify multiple values, or
false
if it may have at most one value.public void setMultiValued(boolean isMultiValued)
isMultiValued
- Indicates whether this argument may be provided more
than once on the command line to specify multiple
values.public boolean needsValue()
true
if a value must be provided with the argument if
it is present, or false
if the argument does not take
a value and the presence of the argument identifier itself is
sufficient to convey the necessary information.public void setNeedsValue(boolean needsValue)
false
to true
,
then a value placeholder must also be provided.
needsValue
- Indicates whether a value must be provided with this
argument if it is present.public Message getValuePlaceholder()
null
if there is
none.public void setValuePlaceholder(Message valuePlaceholder)
null
only if
needsValue()
returns false
.
valuePlaceholder
- The value placeholder that will be displayed for
this argument in the generated usage information.public java.lang.String getDefaultValue()
null
if there is no default value.public void setDefaultValue(java.lang.String defaultValue)
defaultValue
- The default value that will be used for this argument
if it is not specified on the command line and it is
not set from a properties file.public java.lang.String getPropertyName()
getDefaultValue
, but the properties file value will be
overridden by a value supplied on the command line.
public void setPropertyName(java.lang.String propertyName)
propertyName
- The name of a property in a properties file that may
be used to set the default value for this argument if
it is present.public boolean isValueSetByProperty()
true
if this argument was provided in the
set of properties found is a properties file, or
false
if not.public void setValueSetByProperty(boolean isValueSetByProperty)
isValueSetByProperty
- Specify whether this argument was provided in the set
of properties found is a properties file.public Message getDescription()
public boolean hasValue()
true
if this argument has at least one value, or
false
if it does not have any values.public java.lang.String getValue()
null
if there
are no values and no default value has been given.public java.util.LinkedList<java.lang.String> getValues()
public int getIntValue() throws ArgumentException
ArgumentException
- If there are multiple values, or the value
cannot be parsed as an integer.public java.util.LinkedList<java.lang.Integer> getIntValues() throws ArgumentException
ArgumentException
- If any of the values cannot be parsed as an
integer.public boolean getBooleanValue() throws ArgumentException
Boolean
.
Boolean
.
ArgumentException
- If this argument cannot be interpreted as a
Boolean value.public abstract boolean valueIsAcceptable(java.lang.String valueString, MessageBuilder invalidReason)
valueString
- The value for which to make the determination.invalidReason
- A buffer into which the invalid reason may be
written if the value is not acceptable.
true
if the value is acceptable, or
false
if it is not.public void addValue(java.lang.String valueString)
valueIsAcceptable
method.
valueString
- The string representation of the value to add to this
argument.public void clearValues()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |