org.pfsw.text
Enum ByteSizeUnit

java.lang.Object
  extended by java.lang.Enum<ByteSizeUnit>
      extended by org.pfsw.text.ByteSizeUnit
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ByteSizeUnit>

public enum ByteSizeUnit
extends java.lang.Enum<ByteSizeUnit>

This enum provides several memory size units with an associated factor that is useful to calculate the number of bytes from a value given in a different memory size unit. See also http://en.wikipedia.org/wiki/IEEE_1541-2002


Enum Constant Summary
BYTES
           
EXA_BYTES
           
GIGA_BYTES
           
KILO_BYTES
           
MEGA_BYTES
           
PETA_BYTES
           
TERA_BYTES
           
 
Method Summary
static ByteSizeUnit findByPrefix(java.lang.String str)
          Returns the ByteSiteUnit enum value that matches the given string.
 java.math.BigDecimal getBytesFactor()
          Returns the multiplication factor for this unit to convert a corresponding value to its number of bytes.
 java.lang.String getCommonnName()
          Returns the commonly used (but incorrect) name of the unit.
 java.lang.String getCommonPrefix()
          Returns the commonly used (but incorrect) short name of the unit.
 long getFactor()
          Returns the multiplication factor for this unit to convert a corresponding value to its number of bytes as long value.
 java.lang.String getIEEE1541Name()
          Returns the standardized IEEE 1541 name of the unit.
 java.lang.String getIEEE1541Prefix()
          Returns the standardized IEEE 1541 prefix of the unit.
 int getPowerOf1024()
          Returns the power of 1024 (bytes) this unit represents.
static ByteSizeUnit valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static ByteSizeUnit[] 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

BYTES

public static final ByteSizeUnit BYTES

KILO_BYTES

public static final ByteSizeUnit KILO_BYTES

MEGA_BYTES

public static final ByteSizeUnit MEGA_BYTES

GIGA_BYTES

public static final ByteSizeUnit GIGA_BYTES

TERA_BYTES

public static final ByteSizeUnit TERA_BYTES

PETA_BYTES

public static final ByteSizeUnit PETA_BYTES

EXA_BYTES

public static final ByteSizeUnit EXA_BYTES
Method Detail

values

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

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

valueOf

public static ByteSizeUnit valueOf(java.lang.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:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

findByPrefix

public static ByteSizeUnit findByPrefix(java.lang.String str)
Returns the ByteSiteUnit enum value that matches the given string.

Parameters:
str - The prefix value to be used for the look-up.
Returns:
The found enum or null if not found.

getPowerOf1024

public int getPowerOf1024()
Returns the power of 1024 (bytes) this unit represents.


getCommonnName

public java.lang.String getCommonnName()
Returns the commonly used (but incorrect) name of the unit.


getCommonPrefix

public java.lang.String getCommonPrefix()
Returns the commonly used (but incorrect) short name of the unit.


getIEEE1541Name

public java.lang.String getIEEE1541Name()
Returns the standardized IEEE 1541 name of the unit.


getIEEE1541Prefix

public java.lang.String getIEEE1541Prefix()
Returns the standardized IEEE 1541 prefix of the unit.


getBytesFactor

public java.math.BigDecimal getBytesFactor()
Returns the multiplication factor for this unit to convert a corresponding value to its number of bytes.


getFactor

public long getFactor()
Returns the multiplication factor for this unit to convert a corresponding value to its number of bytes as long value.