public class CmdArgsParser
extends java.lang.Object
| Constructor and Description |
|---|
CmdArgsParser(java.lang.String[] args)
Creates a new instance with the given arguments
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String[] |
getAnonymousArgs() |
java.lang.String |
getArg(java.lang.String argName)
Returns the string value of the given argument.
|
java.lang.String |
getArg(java.lang.String argName, java.lang.String defaultValue)
Returns the string value of the given argument.
|
java.lang.String[] |
getArrayArg(java.lang.String argName, boolean required, java.lang.String[] defaultValue)
Gets the string array value of an argument
|
java.lang.Boolean |
getBooleanArg(java.lang.String argName, boolean required, java.lang.Boolean defaultValue)
Gets the boolean value of an argument
|
boolean[] |
getBooleanArrayArg(java.lang.String argName, boolean required, boolean[] defaultValue)
Gets the boolean array value of an argument
|
java.lang.Class<?> |
getClassArg(java.lang.String argName, boolean required, java.lang.Class<?> defaultValue)
Gets the class value of an argument
|
java.lang.Double |
getDoubleArg(java.lang.String argName, boolean required, java.lang.Double defaultValue)
Gets the double value of an argument
|
double[] |
getDoubleArrayArg(java.lang.String argName, boolean required, double[] defaultValue)
Gets the double array value of an argument
|
java.lang.Integer |
getIntArg(java.lang.String argName, boolean required, java.lang.Integer defaultValue)
Gets the integer value of an argument
|
int[] |
getIntArrayArg(java.lang.String argName, boolean required, int[] defaultValue)
Gets the integer array value of an argument
|
java.lang.Long |
getLongArg(java.lang.String argName, boolean required, java.lang.Long defaultValue)
Gets the long value of an argument
|
long[] |
getLongArrayArg(java.lang.String argName, boolean required, long[] defaultValue)
Gets the long array value of an argument
|
java.lang.String |
getRequiredArg(java.lang.String argName)
Validates that the given argument exists and returns its string value.
|
public CmdArgsParser(java.lang.String[] args)
args - command line argumentspublic java.lang.String[] getAnonymousArgs()
public java.lang.String getArg(java.lang.String argName)
argName - an argument name
public java.lang.String getArg(java.lang.String argName,
java.lang.String defaultValue)
argName - an argument namedefaultValue - the value to return in case the argument is not found
public java.lang.String[] getArrayArg(java.lang.String argName,
boolean required,
java.lang.String[] defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.
public java.lang.Boolean getBooleanArg(java.lang.String argName,
boolean required,
java.lang.Boolean defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.
public boolean[] getBooleanArrayArg(java.lang.String argName,
boolean required,
boolean[] defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.
public java.lang.Class<?> getClassArg(java.lang.String argName,
boolean required,
java.lang.Class<?> defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.
public java.lang.Double getDoubleArg(java.lang.String argName,
boolean required,
java.lang.Double defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.
public double[] getDoubleArrayArg(java.lang.String argName,
boolean required,
double[] defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.
public java.lang.Integer getIntArg(java.lang.String argName,
boolean required,
java.lang.Integer defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.
public int[] getIntArrayArg(java.lang.String argName,
boolean required,
int[] defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.
public java.lang.Long getLongArg(java.lang.String argName,
boolean required,
java.lang.Long defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.
public long[] getLongArrayArg(java.lang.String argName,
boolean required,
long[] defaultValue)
argName - the argument namerequired - whether the argument is required or not. In case it is required and not found, an IllegalStateException will be thrown.defaultValue - the default value used in case the argument is not found and not required.public java.lang.String getRequiredArg(java.lang.String argName)
IllegalStateException will be thrownargName - an argument nameCopyright © 2016 Oracle and/or its affiliates. All Rights Reserved.