net.jolsrv2.utils
Class Mantissa

java.lang.Object
  extended by net.jolsrv2.utils.Mantissa

public class Mantissa
extends java.lang.Object

The class includes helper functions for the encoding/decoding of time in TLVs as described in RFC3626.

Author:
Andreas Schjønhaug

Constructor Summary
Mantissa()
           
 
Method Summary
static long decode(byte x)
          The method decodes a byte encoded represented in mantissa/exponent format.
static byte encode(double t)
          The method encodes a double (in seconds) to mantissa/exponent format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mantissa

public Mantissa()
Method Detail

decode

public static final long decode(byte x)
The method decodes a byte encoded represented in mantissa/exponent format. time = C*(1+a/16)*2^b (in seconds) where a is the integer represented by the four highest bits of the byte and b the integer represented by the four lowest bits of the byte.

Parameters:
x - the encoded byte
Returns:
the time in long

encode

public static final byte encode(double t)
The method encodes a double (in seconds) to mantissa/exponent format.

Parameters:
t - the time to encode
Returns:
a byte in mantissa/exponent representation