galaxy.util
Class ArgParser
java.lang.Object
|
+--galaxy.util.ArgParser
- Direct Known Subclasses:
- ServerArgParser
- public class ArgParser
- extends java.lang.Object
The argument parser processes an array of arguments (key/values pairs).
Constructor Summary |
ArgParser(java.lang.String[] args)
Construct an argument parser for the given arguments. |
Method Summary |
java.util.List |
getArg(java.lang.String argName)
Return the value of the specified argument. |
java.util.List |
getArg(java.lang.String argName,
java.util.List defaultValue)
Return the value of the specified argument. |
int |
getIntegerArg(java.lang.String argName,
int defaultValue)
Return the integer value of the specified argument. |
java.lang.String |
getStringArg(java.lang.String argName,
java.lang.String defaultValue)
Return the string value of the specified argument. |
boolean |
isArg(java.lang.String argName)
Tests if the specified argument exists. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ArgParser
public ArgParser(java.lang.String[] args)
- Construct an argument parser for the given arguments. Argument names
must be prepended with a dash (-) character, and all argument names and
values must be separated with whitespace.
- Parameters:
args
- the argument list (consisting of argument keys and values)
isArg
public boolean isArg(java.lang.String argName)
- Tests if the specified argument exists. Note that the dash must be
included in the argument name.
- Parameters:
argName
- the argument name- Returns:
- true if the named argument exists, false otherwise
getArg
public java.util.List getArg(java.lang.String argName)
- Return the value of the specified argument. Note that the dash must be
included in the argument name.
- Parameters:
argName
- the argument name- Returns:
- the value of the argument or null if it has no value (or the
argument does not exist)
getArg
public java.util.List getArg(java.lang.String argName,
java.util.List defaultValue)
- Return the value of the specified argument. Note that the dash must be
included in the argument name. If the argument does not exist, the
specified default value is returned.
- Parameters:
argName
- the argument namedefaultValue
- the default argument value- Returns:
- the value of the argument or the default value if it has no
value (or the argument does not exist)
getStringArg
public java.lang.String getStringArg(java.lang.String argName,
java.lang.String defaultValue)
- Return the string value of the specified argument. Note that the dash
must be included in the argument name. If the argument does not exist,
the specified default value is returned. Note that if this method is
called for an argument that consists of multiple argument values, only
the first argument value will be processed.
- Parameters:
argName
- the argument namedefaultValue
- the default argument value- Returns:
- the value of the argument or the default value if it has no
value or the argument does not exist
getIntegerArg
public int getIntegerArg(java.lang.String argName,
int defaultValue)
- Return the integer value of the specified argument. Note that the dash
must be included in the argument name. If the argument does not exist
or there is an error while converting the argument value to an integer,
the specified default value is returned. Note that if this method is
called for an argument that consists of multiple argument values, only
the first argument value will be processed.
- Parameters:
argName
- the argument namedefaultValue
- the default argument value- Returns:
- the value of the argument or the default value if it has no
value, the argument does not exist, or there is an error while
converting the argument value to an integer