nl.lxtreme.ols.api.util
Enum FrequencyUnit

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

public enum FrequencyUnit
extends Enum<FrequencyUnit>

Represents a frequency unit that has a displayable representation and a scale factor to convert it from/to Hertz.


Enum Constant Summary
GHZ
          gigahertz.
HZ
          hertz.
KHZ
          kilohertz.
MHZ
          megahertz.
MiHZ
          millihertz.
THZ
          terahertz.
 
Field Summary
static double ZERO_THRESHOLD
          Constant used to determine whether we should show "0Hz".
 
Method Summary
static String format(double aFrequency)
          Convenience method to directly get a displayable represention of a given frequency.
 String format(double aFrequency, int aScale)
          Returns the given frequency as string representation using this frequency unit's display name.
 String getDisplayName()
          Returns display name of this frequency unit, like "Hz" or "MHz".
 double getFactor()
          Returns the scale factor to get from Hertz to this frequency unit.
static FrequencyUnit toUnit(double aFrequency)
          Converts a given period to a FrequencyUnit instance.
static FrequencyUnit valueOf(String name)
          Returns the enum constant of this type with the specified name.
static FrequencyUnit[] 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

MiHZ

public static final FrequencyUnit MiHZ
millihertz.


HZ

public static final FrequencyUnit HZ
hertz.


KHZ

public static final FrequencyUnit KHZ
kilohertz.


MHZ

public static final FrequencyUnit MHZ
megahertz.


GHZ

public static final FrequencyUnit GHZ
gigahertz.


THZ

public static final FrequencyUnit THZ
terahertz.

Field Detail

ZERO_THRESHOLD

public static final double ZERO_THRESHOLD
Constant used to determine whether we should show "0Hz".

See Also:
Constant Field Values
Method Detail

values

public static FrequencyUnit[] 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 (FrequencyUnit c : FrequencyUnit.values())
    System.out.println(c);

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

valueOf

public static FrequencyUnit 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 aFrequency)
Convenience method to directly get a displayable represention of a given frequency.

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

Parameters:
aFrequency - the frequency to get a displayable representation for.
Returns:
a string representation of the given frequency, never null.

toUnit

public static FrequencyUnit toUnit(double aFrequency)
Converts a given period to a FrequencyUnit instance.

Parameters:
aFrequency - the frequency to convert to a FrequencyUnit.
Returns:
a FrequencyUnit instance, never null.

format

public String format(double aFrequency,
                     int aScale)
Returns the given frequency as string representation using this frequency unit's display name.

Parameters:
aFrequency - the frequency 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 frequency, like "1.234kHz", never null.

getDisplayName

public String getDisplayName()
Returns display name of this frequency unit, like "Hz" or "MHz".

Returns:
a display name, never null.

getFactor

public double getFactor()
Returns the scale factor to get from Hertz to this frequency unit.

Returns:
a scale factor, >= 1.0.


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