Cumulus4j API
(1.2.0-SNAPSHOT)

org.cumulus4j.keymanager.cli
Class TimePeriodOptionHandler

java.lang.Object
  extended by org.kohsuke.args4j.spi.OptionHandler<T>
      extended by org.kohsuke.args4j.spi.OneArgumentOptionHandler<Long>
          extended by 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

Nested Class Summary
static class TimePeriodOptionHandler.Unit
          Units based on ISO 31-1 (where it exists).
 
Field Summary
 
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)
           
 
Method Summary
protected  Long parse(String argument)
           
 
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
 

Constructor Detail

TimePeriodOptionHandler

public TimePeriodOptionHandler(org.kohsuke.args4j.CmdLineParser parser,
                               org.kohsuke.args4j.OptionDef option,
                               org.kohsuke.args4j.spi.Setter<Long> setter)
Method Detail

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

Cumulus4j API
(1.2.0-SNAPSHOT)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.