|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjcmdline.AbstractParameter<java.util.Date>
jcmdline.DateTimeParam
public class DateTimeParam
A parameter that accepts a date and time as its value.
The format for the date is taken from the strings
ResourceBundle. The format for the time is "HH:mm:ss:SSS", where the seconds
and/or milliseconds portion may be left off by the user, in which case they
will be defaulted.
Sample Usage:
DateTimeParam startTimeParam =
new DateTimeParam("startTime",
"start time of report",
DateTimeParam.REQUIRED);
DateTimeParam endTimeParam =
new DateTimeParam("endTime",
"end time of report",
DateTimeParam.REQUIRED);
// Seconds and millis for startTime will both be 0 by default.
// Set the seconds and millis for the end of the report to be the end
// of a minute.
endTimeParam.setDefaultSeconds(59);
endTimeParam.setDefaultMilliSeconds(999);
CmdLineHandler cl = new DefaultCmdLineHandler(
"myreport", "generate activity report",
new Parameter[] {},
new Parameter[] { startTimeParam, endTimeParam });
cl.parse();
// Don't need to check isSet() because params are REQUIRED
Date stTime = startTimeParam.getValue();
Date enTime = endTimeParam.getValue();
.
.
This will result in a command line that may be executed as:
myreport "09/23/59 10:12" "09/23/59 23:34"or
myreport "09/23/59 10:12:34:567" "09/23/59 23:34:34:567"
DateParam,
TimeParam| Field Summary |
|---|
| Fields inherited from class jcmdline.AbstractParameter |
|---|
acceptableValues, desc, hidden, ignoreRequired, multiValued, optional, optionLabel, set, tag, values |
| Fields inherited from interface jcmdline.Parameter |
|---|
HIDDEN, MULTI_VALUED, OPTIONAL, PUBLIC, REQUIRED, SINGLE_VALUED |
| Constructor Summary | |
|---|---|
DateTimeParam(java.lang.String tag,
java.lang.String desc)
constructor - creates single-valued, optional, public parameter |
|
DateTimeParam(java.lang.String tag,
java.lang.String desc,
boolean optional)
constructor - creates single-valued, public parameter which will will be either optional or required, as specified. |
|
DateTimeParam(java.lang.String tag,
java.lang.String desc,
boolean optional,
boolean multiValued)
constructor - creates a public parameter which will will be either optional or required, and/or multi-valued, as specified. |
|
DateTimeParam(java.lang.String tag,
java.lang.String desc,
boolean optional,
boolean multiValued,
boolean hidden)
constructor - creates a parameter which will will be either optional or required, single or multi-valued, and hidden or public as specified. |
|
DateTimeParam(java.lang.String tag,
java.lang.String desc,
java.util.Date[] acceptableValues)
constructor - creates a single-valued, optional, public, number parameter whose value must be one of the specified values. |
|
DateTimeParam(java.lang.String tag,
java.lang.String desc,
java.util.Date[] acceptableValues,
boolean optional)
constructor - creates a single-valued, public, number parameter whose value must be one of the specified values, and which is required or optional, as specified. |
|
DateTimeParam(java.lang.String tag,
java.lang.String desc,
java.util.Date[] acceptableValues,
boolean optional,
boolean multiValued)
constructor - creates a public number parameter whose value must be one of the specified values, and which is required or optional and/or multi-valued, as specified. |
|
DateTimeParam(java.lang.String tag,
java.lang.String desc,
java.util.Date[] acceptableValues,
boolean optional,
boolean multiValued,
boolean hidden)
constructor - creates a Parameter, all of whose options are specified. |
|
| Method Summary | |
|---|---|
java.util.Date |
convertValue(java.lang.String val)
Converts a String value to its Date equivalent, filling in default seconds and milliseconds as necessary. |
int |
getDefaultMilliSeconds()
Gets the default millisecond value to use if not specified by the user. |
int |
getDefaultSeconds()
Gets the seconds default to use if not specified by the user. |
static java.lang.String |
getParseFormat()
Gets the format used to parse the date/time values. |
void |
setDefaultMilliSeconds(int defaultMilliSeconds)
Sets the default millisecond value to use if not specified by the user. |
void |
setDefaultSeconds(int defaultSeconds)
Sets the seconds default to use if not specified by the user. |
| Methods inherited from class jcmdline.AbstractParameter |
|---|
addStringValue, addValue, getAcceptableValues, getDesc, getIgnoreRequired, getOptionLabel, getTag, getValue, getValues, isHidden, isMultiValued, isOptional, isSet, setAcceptableValues, setAcceptableValues, setDesc, setHidden, setIgnoreRequired, setMultiValued, setOptional, setOptionLabel, setTag, setValue, setValues, setValues, validateValue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DateTimeParam(java.lang.String tag,
java.lang.String desc)
tag - a unique identifier for this parameterdesc - a description of the parameter, suitable for display in a
usage statement
java.lang.IllegalArgumentException - if tag or setTag(),
setDesc()
public DateTimeParam(java.lang.String tag,
java.lang.String desc,
boolean optional)
tag - a unique identifier for this parameterdesc - a description of the parameter, suitable for display in a
usage statementoptional - OPTIONAL if optional,
REQUIRED if required
java.lang.IllegalArgumentException - if any of the specified parameters are invalid.setTag(),
setDesc()
public DateTimeParam(java.lang.String tag,
java.lang.String desc,
boolean optional,
boolean multiValued)
tag - a unique identifier for this parameterdesc - a description of the parameter, suitable for display in a
usage statementoptional - OPTIONAL if optional,
REQUIRED if requiredmultiValued - MULTI_VALUED if the parameter
can accept multiple values, SINGLE_VALUED if the parameter can contain only a single
value
java.lang.IllegalArgumentException - if any of the specified parameters are invalid.setTag(),
setDesc(),
SINGLE_VALUED,
MULTI_VALUED
public DateTimeParam(java.lang.String tag,
java.lang.String desc,
boolean optional,
boolean multiValued,
boolean hidden)
tag - a unique identifier for this parameterdesc - a description of the parameter, suitable for display in a
usage statementoptional - OPTIONAL if optional,
REQUIRED if requiredmultiValued - MULTI_VALUED if the parameter
can accept multiple values, SINGLE_VALUED if the parameter can contain only a single
valuehidden - HIDDEN if parameter is not to be
listed in the usage, PUBLIC
otherwise.
java.lang.IllegalArgumentException - if any of the specified parameters are invalid.setTag(),
setDesc(),
SINGLE_VALUED,
MULTI_VALUED,
HIDDEN,
PUBLIC
public DateTimeParam(java.lang.String tag,
java.lang.String desc,
java.util.Date[] acceptableValues)
tag - the tag associated with this parameterdesc - a description of the parameter, suitable for display in a
usage statementacceptableValues - the acceptable values for the parameter
java.lang.IllegalArgumentException - if any parameter is invalid.setTag(),
setDesc(),
setAcceptableValues()
public DateTimeParam(java.lang.String tag,
java.lang.String desc,
java.util.Date[] acceptableValues,
boolean optional)
tag - the tag associated with this parameterdesc - a description of the parameter, suitable for display in a
usage statementacceptableValues - the acceptable values for the parameteroptional - OPTIONAL if optional,
REQUIRED if required
java.lang.IllegalArgumentException - if any parameter is invalid.setTag(),
setDesc(),
setAcceptableValues(),
OPTIONAL,
REQUIRED
public DateTimeParam(java.lang.String tag,
java.lang.String desc,
java.util.Date[] acceptableValues,
boolean optional,
boolean multiValued)
tag - the tag associated with this parameterdesc - a description of the parameter, suitable for display in a
usage statementacceptableValues - the acceptable values for the parameteroptional - OPTIONAL if optional,
REQUIRED if requiredmultiValued - MULTI_VALUED if the parameter
can accept multiple values, SINGLE_VALUED if the parameter can contain only a single
value
java.lang.IllegalArgumentException - if any parameter is invalid.setTag(),
setDesc(),
setAcceptableValues(),
OPTIONAL,
REQUIRED,
SINGLE_VALUED,
MULTI_VALUED
public DateTimeParam(java.lang.String tag,
java.lang.String desc,
java.util.Date[] acceptableValues,
boolean optional,
boolean multiValued,
boolean hidden)
tag - the tag associated with this parameterdesc - a description of the parameter, suitable for display in a
usage statementacceptableValues - the acceptable values for the parameteroptional - OPTIONAL if optional,
REQUIRED if requiredmultiValued - MULTI_VALUED if the parameter
can accept multiple values, SINGLE_VALUED if the parameter can contain only a single
valuehidden - HIDDEN if parameter is not to be
listed in the usage, PUBLIC
otherwise.
java.lang.IllegalArgumentException - if any parameter is invalid.setTag(),
setDesc(),
setAcceptableValues(),
OPTIONAL,
REQUIRED,
SINGLE_VALUED,
MULTI_VALUED,
HIDDEN,
PUBLIC| Method Detail |
|---|
public static java.lang.String getParseFormat()
public java.util.Date convertValue(java.lang.String val)
throws CmdLineException
convertValue in class AbstractParameter<java.util.Date>val - the String to be converted
val
java.text.ParseException - if val will not parse to a Date.
CmdLineException - if the conversion cannot be madepublic int getDefaultMilliSeconds()
setDefaultMilliSeconds()public int getDefaultSeconds()
setDefaultSeconds()public void setDefaultMilliSeconds(int defaultMilliSeconds)
defaultMilliSeconds - the default millisecond value to use if not specified by the
usergetDefaultMilliSeconds()public void setDefaultSeconds(int defaultSeconds)
defaultSeconds - the seconds default to use if not specified by the usergetDefaultSeconds()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||