E - argument typepublic abstract class AbstractArgument<E> extends Object implements Argument<E>
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractArgument(String shortName,
String longName,
String description,
boolean required)
Create a new abstract argument.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract E |
convert(String s)
Convert the specified string value into an instance
of class
E. |
boolean |
equals(Object o) |
String |
getDescription()
Return the description of this argument.
|
String |
getLongName()
Return the long name of this argument.
|
String |
getShortName()
Return the short name of this argument.
|
E |
getValue()
Return the value of this argument.
|
E |
getValue(E defaultValue)
Return the value of this argument or the specified default value
if this argument was not found in the command line.
|
int |
hashCode() |
protected boolean |
isArgumentString(String s)
Return true if the specified string is an argument name.
|
boolean |
isRequired()
Return true if this argument is required.
|
protected boolean |
isValueString(String s)
Return true if the specified string is a value.
|
void |
visit(String current,
CommandLine commandLine)
Visit the specified argument string from the specified command line.
|
boolean |
wasFound()
Return true if this argument was found in the
command line, false if it was not found or if
this argument has not visited a command line
yet.
|
protected AbstractArgument(String shortName, String longName, String description, boolean required)
shortName - short argument namelongName - long argument namedescription - argument descriptionrequired - true if this argument is requiredpublic final void visit(String current, CommandLine commandLine) throws Exception
Previous and next argument strings in the command line may be interrogated by this argument, but the cursor position of the command line must be reset to what it was at the beginning of this method invocation.
protected boolean isArgumentString(String s)
s - stringprotected boolean isValueString(String s)
s - stringprotected abstract E convert(String s) throws Exception
E.s - string valueE converted
from the specified string valueException - if an error occurspublic final String getShortName()
getShortName in interface Argument<E>public final String getLongName()
getLongName in interface Argument<E>public final String getDescription()
getDescription in interface Argument<E>public final boolean isRequired()
isRequired in interface Argument<E>public final boolean wasFound()
wasFound in interface Argument<E>Argument.visit(String, CommandLine)public final E getValue()
public final E getValue(E defaultValue)
Copyright © 2004–2022 dishevelled.org. All rights reserved.