Class ParameterParser


  • public class ParameterParser
    extends java.lang.Object
    Wrapper class to avoid code duplication of common parsing requirements.
    Author:
    Steinar Knutsen
    • Constructor Summary

      Constructors 
      Constructor Description
      ParameterParser()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Long asMilliSeconds​(java.lang.Object value, java.lang.Long defaultValue)
      Tries to return the given object as a Long.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParameterParser

        public ParameterParser()
    • Method Detail

      • asMilliSeconds

        public static java.lang.Long asMilliSeconds​(java.lang.Object value,
                                                    java.lang.Long defaultValue)
        Tries to return the given object as a Long. If it is a Number, treat it as a number of seconds, i.e. get a Long representation and multiply by 1000. If it has a String representation, try to parse this as a floating point number, followed by by an optional unit (seconds and an SI prefix, a couple of valid examples are "s" and "ms". Only a very small subset of SI prefixes are supported). If no unit is given, seconds are assumed.
        Parameters:
        value - some representation of a number of seconds
        defaultValue - returned if value is null
        Returns:
        value as a number of milliseconds
        Throws:
        java.lang.NumberFormatException - if value is not a Number instance and its String representation cannot be parsed as a number followed optionally by time unit