org.cumulus4j.keymanager.cli
Class TimePeriodOptionHandler
java.lang.Object
org.kohsuke.args4j.spi.OptionHandler<T>
org.kohsuke.args4j.spi.OneArgumentOptionHandler<Long>
org.cumulus4j.keymanager.cli.TimePeriodOptionHandler
public class TimePeriodOptionHandler
- extends org.kohsuke.args4j.spi.OneArgumentOptionHandler<Long>
Option handler implementation to interprete a time period (e.g. "5 minutes".
The time period is specified in the command line by writing a number
directly followed (no space!) by a unit. For example 5 minutes could be
written as "5min" or "300s" (300 seconds are 5 minutes).
This handler can be chosen for every long
property using
the Option
annotation like this:
@Option(name="-myArg", handler=TimePeriodOptionHandler.class)
private long myArg;
The long
property will be set to the milliseconds value.
For example, if the command line user passes "5min", the long
value
will be 300000 (5 min * 60 s * 1000 ms).
- Author:
- Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de
Fields inherited from class org.kohsuke.args4j.spi.OptionHandler |
option, owner, setter |
Constructor Summary |
TimePeriodOptionHandler(org.kohsuke.args4j.CmdLineParser parser,
org.kohsuke.args4j.OptionDef option,
org.kohsuke.args4j.spi.Setter<Long> setter)
|
Methods inherited from class org.kohsuke.args4j.spi.OneArgumentOptionHandler |
getDefaultMetaVariable, parseArguments |
Methods inherited from class org.kohsuke.args4j.spi.OptionHandler |
getMetaVariable, getNameAndMeta |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TimePeriodOptionHandler
public TimePeriodOptionHandler(org.kohsuke.args4j.CmdLineParser parser,
org.kohsuke.args4j.OptionDef option,
org.kohsuke.args4j.spi.Setter<Long> setter)
parse
protected Long parse(String argument)
throws NumberFormatException,
org.kohsuke.args4j.CmdLineException
- Specified by:
parse
in class org.kohsuke.args4j.spi.OneArgumentOptionHandler<Long>
- Throws:
NumberFormatException
org.kohsuke.args4j.CmdLineException
Copyright © 2012 NightLabs Consulting GmbH. All Rights Reserved.