|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javatools.util.ArgumentProcessor
It's a class useful to process arguments passed via command line.
Constructor Summary | |
ArgumentProcessor()
Creates new ArgumentProcessor |
Method Summary | |
void |
cleanValues()
Turns all flags to FALSE and all values to empty strings |
java.lang.String |
getArgumentHelpText(int argPos,
java.lang.String paramName)
Returns the help text whose position is specified. |
java.lang.String |
getArgumentHelpText(java.lang.String argName,
java.lang.String paramName)
Returns the help text of an argument whose name is specified. |
java.lang.String |
getArgumentName(int argPos)
Returns the name of an argument. |
int |
getArgumentPos(java.lang.String argName)
Returns the position of an argument. |
java.lang.String |
getArgumentValue(int argPos)
Returns the value of an argument whose position is specified. |
java.lang.String |
getArgumentValue(java.lang.String argName)
Return the value of an argument whose name is specified. |
java.lang.String |
getFlagHelpText(int numFlag)
Returns help text of a flag whose position is specified. |
java.lang.String |
getFlagHelpText(java.lang.String flagName)
Returns help text of a flag whose name is specified. |
java.lang.String |
getFlagName(int numFlag)
Returns the name of the flag. |
int |
getFlagPos(java.lang.String flagName)
Returns the position of the flag. |
boolean |
getFlagValue(int flagPos)
The value of a flag whose position is specified. |
boolean |
getFlagValue(java.lang.String flagName)
Returns the value of a flag whose name is specified. |
int |
getNumArguments()
Returns the number of arguments. |
int |
getNumFlags()
Returns the number of flags. |
void |
processArguments(java.lang.String[] args)
Process the command line parameters. |
void |
setArgumentHelpText(int argPos,
java.lang.String helpText)
Sets help text for an argument whose position is specified. |
void |
setArgumentHelpText(java.lang.String argName,
java.lang.String helpText)
Sets help text for an argument whose name is specified. |
void |
setArgumentName(int argPos,
java.lang.String argName)
Sets the name of an argument. |
void |
setArgumentValue(int argPos,
java.lang.String argValue)
Sets the value of an argument whose position is specified. |
void |
setArgumentValue(java.lang.String argName,
java.lang.String argValue)
Sets the value of an argument, whose name is specified. |
void |
setFlagHelpText(int numFlag,
java.lang.String helpText)
Sets help text for a flag whose position is specified. |
void |
setFlagHelpText(java.lang.String flagName,
java.lang.String helpText)
Sets help text for a flag whose name is specified. |
void |
setFlagName(int numFlag,
java.lang.String flagName)
Sets the name of a flag. |
void |
setFlagValue(int flagPos,
boolean flagValue)
Sets the value of a flag whose position is specified. |
void |
setFlagValue(java.lang.String flagName,
boolean flagValue)
Sets the value of a flag whose name is specified. |
void |
setNumArguments(int numArgs)
Sets the number of arguments (parameters with different values, used with to strings in command lines). |
void |
setNumFlags(int numArgs)
Sets the number of flags (parameters with with TRUE-FALSE values, used alone in command lines). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ArgumentProcessor()
Method Detail |
public void setNumFlags(int numArgs) throws java.lang.IndexOutOfBoundsException
numArgs
- Number of flags used.
java.lang.IndexOutOfBoundsException
- If numArgs
is less than 1.public int getNumFlags()
public void setNumArguments(int numArgs) throws java.lang.IndexOutOfBoundsException
numArgs
- Number of arguments used.
java.lang.IndexOutOfBoundsException
- If numArgs
is less than 1.public int getNumArguments()
public void setFlagName(int numFlag, java.lang.String flagName) throws java.lang.IndexOutOfBoundsException
numFlag
- The number of the flag. It has to be between 0
and getNumFlags()-1
.flagName
- The name of the flag.
java.lang.IndexOutOfBoundsException
- If numFlag
is not valid.public java.lang.String getFlagName(int numFlag) throws java.lang.IndexOutOfBoundsException
numFlag
- The position of the flag. It has to be between 0
and getNumFlags()-1
.
java.lang.IndexOutOfBoundsException
- if numFlag
is not valid.public int getFlagPos(java.lang.String flagName)
flagName
- The name of the interested flag.
0
and getNumFlags()-1
.public void setFlagValue(java.lang.String flagName, boolean flagValue)
flagName
- The name of the flag.flagValue
- The value of the flag.public void setFlagValue(int flagPos, boolean flagValue) throws java.lang.IndexOutOfBoundsException
flagPos
- Position of the flag. It has to be between 0
and getNumFlags()-1
.flagValue
- The value of the flag.
java.lang.IndexOutOfBoundsException
- If flagPos
is not valid.public boolean getFlagValue(java.lang.String flagName)
flagName
- The name of the flag.
public boolean getFlagValue(int flagPos) throws java.lang.IndexOutOfBoundsException
flagPos
- The position of the flag. It has to be between 0
and getNumFlags()-1
.
java.lang.IndexOutOfBoundsException
- If flagPos
is not valid.public void setArgumentName(int argPos, java.lang.String argName) throws java.lang.IndexOutOfBoundsException
argPos
- The position of the argument. It has to be between 0
and getNumArguments()-1
.argName
- The name of the argument.
java.lang.IndexOutOfBoundsException
- if argPos
is not valid.public java.lang.String getArgumentName(int argPos) throws java.lang.IndexOutOfBoundsException
argPos
- The position of the argument. It has to be between 0
and getNumArguments()-1
.
java.lang.IndexOutOfBoundsException
- If argPos
is not valid.public int getArgumentPos(java.lang.String argName)
argName
- The name of the argument.
public void setArgumentValue(java.lang.String argName, java.lang.String argValue)
argName
- The name of the argument.argValue
- The value of the argument.public void setArgumentValue(int argPos, java.lang.String argValue) throws java.lang.IndexOutOfBoundsException
argPos
- Position of the argument. It has to be between 0
and getNumArguments()-1
.argValue
- Value of the argument.
java.lang.IndexOutOfBoundsException
- If argPos
is not valid.public java.lang.String getArgumentValue(java.lang.String argName)
argName
- Name of the argument.
public java.lang.String getArgumentValue(int argPos) throws java.lang.IndexOutOfBoundsException
argPos
- Position of the argument. It has to be between 0
and getNumArguments()-1
.
java.lang.IndexOutOfBoundsException
- If argPos
is not valid.public void cleanValues()
public void processArguments(java.lang.String[] args)
args
- The parameters passed via command line.public void setFlagHelpText(java.lang.String flagName, java.lang.String helpText)
flagName
- The name of the flag.helpText
- The help text.public void setFlagHelpText(int numFlag, java.lang.String helpText)
numFlag
- Position of the flag. It has to be between 0
and getNumFlags()-1
.helpText
- The help text.public java.lang.String getFlagHelpText(java.lang.String flagName)
flagName
- The name of the flag.
public java.lang.String getFlagHelpText(int numFlag)
numFlag
- The position of the flag. It has to be between 0
and getNumFlags()-1
.
public void setArgumentHelpText(java.lang.String argName, java.lang.String helpText)
argName
- The name of the argument.helpText
- The help text. Use "%P%"
inside this string to represent the text which will be replaced with a given variable parameter name.public void setArgumentHelpText(int argPos, java.lang.String helpText)
argPos
- The position of the argument. It has to be between 0
and getNumArguments()-1
.helpText
- The help text. Use "%P%"
inside this string to represent the text which will be replaced with a given variable parameter name.public java.lang.String getArgumentHelpText(java.lang.String argName, java.lang.String paramName)
argName
- The name of the argument.paramName
- The variable parameter name replaced inside the help text instead of the substring "%P%"
.
public java.lang.String getArgumentHelpText(int argPos, java.lang.String paramName)
argPos
- The position of the argument. It has to be between 0
and getNumArguments()-1
.paramName
- The variable parameter name replaced inside the help text instead of the substring "%P%"
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |