nl.lxtreme.ols.api.util
Enum UnitOfTime

java.lang.Object
  extended by java.lang.Enum<UnitOfTime>
      extended by nl.lxtreme.ols.api.util.UnitOfTime
All Implemented Interfaces:
Serializable, Comparable<UnitOfTime>

public enum UnitOfTime
extends Enum<UnitOfTime>

Represents a unit of time that can be displayed has a scale factor.


Enum Constant Summary
FS
          femtoseconds.
MS
          milliseconds.
NS
          nanoseconds.
PS
          picoseconds.
S
          seconds.
US
          microseconds.
 
Field Summary
static double ZERO_THRESHOLD
          Constant used to determine whether we should show "0.000 s".
 
Method Summary
static String format(double aTime)
          Convenience method to directly get a displayable represention of a given time value.
 String format(double aTime, int aScale)
          Returns the given time as string representation using this time unit's display name and a fixed number of digits after the decimal separator.
 String formatHumanReadable(double aTime)
          Returns the given time as string representation using this time unit's display name and the least number of digits after the decimal separator.
 String getDisplayName()
          Returns the current value of displayName.
 double getFactor()
          Returns the current value of factor.
 UnitOfTime predecessor()
          Returns the predecessor of this unit of time.
 UnitOfTime successor()
          Returns the successor of this unit of time.
static UnitOfTime toUnit(double aTimeValue)
          Converts a given time value (as double representation, in seconds) to a more suitable unit of time.
static UnitOfTime valueOf(String name)
          Returns the enum constant of this type with the specified name.
static UnitOfTime[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

S

public static final UnitOfTime S
seconds.


MS

public static final UnitOfTime MS
milliseconds.


US

public static final UnitOfTime US
microseconds.


NS

public static final UnitOfTime NS
nanoseconds.


PS

public static final UnitOfTime PS
picoseconds.


FS

public static final UnitOfTime FS
femtoseconds.

Field Detail

ZERO_THRESHOLD

public static final double ZERO_THRESHOLD
Constant used to determine whether we should show "0.000 s".

See Also:
Constant Field Values
Method Detail

values

public static UnitOfTime[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (UnitOfTime c : UnitOfTime.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static UnitOfTime valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

format

public static String format(double aTime)
Convenience method to directly get a displayable represention of a given time value.

This method does the same as calling: toUnit( aTime ).format( aTime, 3 );.

Parameters:
aTime - the time value (in seconds) to get a displayable representation for.
Returns:
a string representation of the given time, never null.

toUnit

public static UnitOfTime toUnit(double aTimeValue)
Converts a given time value (as double representation, in seconds) to a more suitable unit of time.

Parameters:
aTimeValue - the time value (in seconds) to return the unit of time for.
Returns:
a UnitOfTime, never null.

format

public String format(double aTime,
                     int aScale)
Returns the given time as string representation using this time unit's display name and a fixed number of digits after the decimal separator.

Parameters:
aTime - the time (in seconds) to convert to a string representation;
aScale - the scale (= number of digits after decimal separator) to use in the string representation.
Returns:
a string representation of the given time, like "1.453ms", never null.

formatHumanReadable

public String formatHumanReadable(double aTime)
Returns the given time as string representation using this time unit's display name and the least number of digits after the decimal separator.

Parameters:
aTime - the time (in seconds) to convert to a string representation;
aScale - the scale (= number of digits after decimal separator) to use in the string representation.
Returns:
a string representation of the given time, like "1.453ms", never null.

getDisplayName

public String getDisplayName()
Returns the current value of displayName.

Returns:
the displayName

getFactor

public double getFactor()
Returns the current value of factor.

Returns:
the factor

predecessor

public UnitOfTime predecessor()
Returns the predecessor of this unit of time.

Returns:
the predecessor of this unit of time, which is a factor larger than this unit of time. Can be null if no greater unit of time is defined.

successor

public UnitOfTime successor()
Returns the successor of this unit of time.

Returns:
the successor of this unit of time, which is a factor smaller than this unit of time. Can be null if no smaller unit of time is defined.


Copyright © 2012 L'Xtreme IT consultancy. All Rights Reserved.