public abstract class CommandLineOption<T> extends DumpableObject
Constructor and Description |
---|
CommandLineOption(java.lang.String option,
java.lang.String helpText) |
CommandLineOption(java.lang.String option,
java.lang.String argName,
java.lang.String helpText) |
CommandLineOption(java.lang.String option,
java.lang.String argName,
java.lang.String helpText,
boolean isMandatory) |
Modifier and Type | Method and Description |
---|---|
void |
checkValue()
Performs additional checks on the entered option value (i.e. file existence etc..)
|
boolean |
equals(java.lang.Object obj)
Compares the option by the 'option' field.
|
java.lang.String |
getArgumentName()
Returns the name of the argument of this option (if any)
|
java.lang.String |
getDefaultValue() |
java.lang.String |
getEnvVariableName()
Returns the name of the env-variable that contains the default value - if one is defined
|
java.lang.String |
getEnvVariableValue()
Returns the value of the ENV-variable if one is defined.
|
java.lang.String |
getHelpText() |
java.lang.String |
getOption()
Returns the option string (always starts with '-' or '+')
|
java.lang.String |
getOptionAndArgument() |
java.lang.String |
getStringValue()
Returns the string value of this option as read from the commandline
|
abstract T |
getValue()
Returns the parsed value of this option.
|
boolean |
hasArgument()
Tells whether this option expects an argument
|
int |
hashCode() |
boolean |
isMandatory() |
boolean |
isPrintHelp() |
boolean |
isPrintSyntax() |
boolean |
isSecret() |
protected boolean |
isValueTakenFromEnvVariable() |
void |
parseDefaultValue()
If the option value is null but a defaultValue is defined then the latter is applied.
|
void |
parseValue()
Parses the value from the command-line and applies it to this option.
|
protected abstract void |
parseValue(java.lang.String value)
Parses and stores the given value from the command-line to this option.
|
void |
setDefaultValue(java.lang.String defaultValue)
Set a default string value for this option.
|
void |
setEnvVariableName(java.lang.String envVarName)
Defines the name of the ENV-variable which is looked up to find out a default value.
|
void |
setFound(boolean wasFound) |
void |
setHelpText(java.lang.String helpText)
Sets the help text for this option
|
void |
setMandatory(boolean isMandatory)
Defines this option to be required.
|
void |
setPrintHelp(boolean isPrintHelp)
Defines whether a help text is to be printed for this option (true by default).
|
void |
setPrintSyntax(boolean isPrintSyntax)
Defines whether this option is to be printed in the syntax line (false by default).
|
void |
setSecret(boolean isSecret)
Defines whether this is a secret option which is never printed
neither in help text nor in syntax line.
|
void |
setStringValue(java.lang.String value) |
DumpString |
toDumpString(DumpString s)
This method allows subclasses to add values to the existing DumpString of the superclass.
|
ToString |
toString(ToString s)
This method allows subclasses to add values to the existing ToString of the superclass.
|
boolean |
wasFound()
Tells whether this option was found in the command-line.
|
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toString
public CommandLineOption(java.lang.String option, java.lang.String helpText)
public CommandLineOption(java.lang.String option, java.lang.String argName, java.lang.String helpText)
public CommandLineOption(java.lang.String option, java.lang.String argName, java.lang.String helpText, boolean isMandatory)
public final void setEnvVariableName(java.lang.String envVarName)
public final java.lang.String getEnvVariableName()
public final java.lang.String getEnvVariableValue()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean wasFound()
public void setFound(boolean wasFound)
public void setSecret(boolean isSecret)
public boolean isSecret()
public void setPrintHelp(boolean isPrintHelp)
public boolean isPrintHelp()
public void setPrintSyntax(boolean isPrintSyntax)
public boolean isPrintSyntax()
public void setMandatory(boolean isMandatory)
public boolean isMandatory()
public final java.lang.String getOption()
public void setHelpText(java.lang.String helpText)
public final java.lang.String getHelpText()
public final java.lang.String getStringValue()
public final void setStringValue(java.lang.String value)
public void setDefaultValue(java.lang.String defaultValue)
parseDefaultValue()
) and used.public java.lang.String getDefaultValue()
public abstract T getValue()
public final void parseValue() throws java.lang.Exception
parseValue(String)
with the value read from the command linejava.lang.Exception
public final void parseDefaultValue() throws java.lang.Exception
java.lang.Exception
protected final boolean isValueTakenFromEnvVariable()
public void checkValue() throws java.lang.Exception
java.lang.Exception
protected abstract void parseValue(java.lang.String value) throws java.lang.Exception
java.lang.Exception
public final boolean hasArgument()
public final java.lang.String getArgumentName()
public final java.lang.String getOptionAndArgument()
public ToString toString(ToString s)
Dumpable
toString
in interface Dumpable
toString
in class DumpableObject
public DumpString toDumpString(DumpString s)
Dumpable
toDumpString
in interface Dumpable
toDumpString
in class DumpableObject
Copyright © 2014 EsprIT-Systems. All Rights Reserved.