static final int guessLengthFromName ( String aName ) { if ( aName . startsWith ( Constants . PREFIX_SNAPSHOT_INTERVAL ) ) return - 1 ; int unitFactor ; int value ; try { value = Integer . parseInt ( aName . substring ( 0 , aName . length ( ) - 1 ) ) ; } catch ( NumberFormatException e ) { throw new UnknownIntervalLengthException ( "Unsupported Interval name format: " + aName ) ; } char lastChar = aName . charAt ( aName . length ( ) - 1 ) ; TimeUnit unit = lookupMap . get ( Character . toLowerCase ( lastChar ) ) ; if ( unit == null ) throw new UnknownIntervalLengthException ( aName + ", " + lastChar + " is not a supported unit." ) ; unitFactor = unit . getFactor ( ) ; if ( value == 0 ) throw new UnknownIntervalLengthException ( aName + ", zero duration is not allowed." ) ; return value * unitFactor ; }
This method parses the given Interval name and returns the length of such an Interval in seconds .