Serializable
, Comparable<ByteSizeUnit>
public enum ByteSizeUnit extends Enum<ByteSizeUnit>
ByteSize
can have.
A byte size unit has a ByteSizeStandard
that dictates the base value to be raised to a given power as well
as the power value that dictates the magnitude of the unit. For example, a unit having the SI standard with a power
value of 4 is known as a terabyte while a unit having the IEC standard with a power value of 4 is known as a
tebibyte. The former has a factor of 1000^4 while the latter has a factor of 1024^4.Enum Constant | Description |
---|---|
BYTES |
The base unit.
|
EXABYTES |
The SI exabyte.
|
EXBIBYTES |
The IEC exibyte.
|
GIBIBYTES |
The IEC gibibyte.
|
GIGABYTES |
The SI gigabyte.
|
KIBIBYTES |
The IEC kibibyte.
|
KILOBYTES |
The SI kilobyte.
|
MEBIBYTES |
The IEC mebibyte.
|
MEGABYTES |
The SI megabyte.
|
PEBIBYTES |
The IEC pebibyte.
|
PETABYTES |
The SI petabyte.
|
TEBIBYTES |
The IEC tebibyte.
|
TERABYTES |
The SI terabyte.
|
YOBIBYTES |
The IEC yobibyte.
|
YOTTABYTES |
The SI yottabyte.
|
ZEBIBYTES |
The IEC zebibyte.
|
ZETTABYTES |
The SI zettabyte.
|
Modifier and Type | Method | Description |
---|---|---|
BigDecimal |
getFactor() |
Gets the multiplication factor for this
ByteSizeUnit . |
boolean |
isIEC() |
Returns whether this
ByteSizeUnit is an IEC unit. |
boolean |
isSI() |
Returns whether this
ByteSizeUnit is an SI unit. |
static ByteSizeUnit |
parse(String unit) |
Parses a string representation of a byte size unit and returns the corresponding
ByteSizeUnit . |
String |
toStringLongForm() |
Returns the long string representation of this unit, such as "kilobytes", "megabytes" or "bytes".
|
String |
toStringShortForm() |
Returns the short string representation of this unit, such as "KiB", "B" or "MB".
|
static ByteSizeUnit |
valueOf(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.
|
public static final ByteSizeUnit BYTES
public static final ByteSizeUnit KILOBYTES
public static final ByteSizeUnit KIBIBYTES
public static final ByteSizeUnit MEGABYTES
public static final ByteSizeUnit MEBIBYTES
public static final ByteSizeUnit GIGABYTES
public static final ByteSizeUnit GIBIBYTES
public static final ByteSizeUnit TERABYTES
public static final ByteSizeUnit TEBIBYTES
public static final ByteSizeUnit PETABYTES
public static final ByteSizeUnit PEBIBYTES
public static final ByteSizeUnit EXABYTES
public static final ByteSizeUnit EXBIBYTES
public static final ByteSizeUnit ZETTABYTES
public static final ByteSizeUnit ZEBIBYTES
public static final ByteSizeUnit YOTTABYTES
public static final ByteSizeUnit YOBIBYTES
public static ByteSizeUnit[] values()
for (ByteSizeUnit c : ByteSizeUnit.values()) System.out.println(c);
public static ByteSizeUnit valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static ByteSizeUnit parse(String unit)
ByteSizeUnit
.
There is support for various formats. Below is a list describing them where [prefix] represents the long form
prefix of the unit (such as "kilo", "mega", "tera", etc) and [first] represents the first letter in the prefix
(such as "k", "m", "t", etc):
BYTES
BYTES
.ByteSizeStandard
is being used.ByteSizeStandard
is being used.ByteSizeStandard.IEC
standard for the corresponding prefix, eg. "k" is equal to "kibibyte"ByteSizeStandard.IEC
standard for the corresponding prefix, eg. "ki" is equal to "kibibyte"ByteSizeStandard.IEC
standard for the corresponding prefix, eg. "kib" is equal to "kibibyte"ByteSizeStandard.SI
standard for the corresponding prefix, eg. "kb" is equal to "kilobyte"null
if the specified string is not a valid ByteSizeUnit
string as
described above.unit
- the string representation of the desired ByteSizeUnit
.ByteSizeUnit
represented by the specified string or null
if the string could
not be translated into a known unit.public boolean isSI()
ByteSizeUnit
is an SI unit.public boolean isIEC()
ByteSizeUnit
is an IEC unit.public BigDecimal getFactor()
ByteSizeUnit
.
Returns the result of raising the poweOf value of this units standard to the power specified in this unit.public String toStringLongForm()
public String toStringShortForm()
Copyright © 2012–2020 Luigi R. Viggiano. All rights reserved.