- All Implemented Interfaces:
Serializable,Comparable<Scale>,Constable
A collection of byte prefixes with conversions and formatting.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionA byte.SI Scale GigabttesIEC Scale Gigabytes (2 ^ 30)SI scale Kilobytes bytesIEC Scale Kilobytes (2 ^ 10).SI scale MegabytesIEC Scale Megabytes (2 ^ 20)SI Scale PetabytesIEC Scale Petabytes (2 ^ 50)SI Scale TerabytesIEC Scale Terabytes (2 ^ 40) -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionlongasBytes(double unitCount) Gets the number of bytes found in the specified number of units.displayValue(long value) Creates a String using the scale. if the scale is notBthen it is followed by the number of bytes within a set of parenthesis.format(long byteCount) Formats thebyteCountat this scale.static ScaleDetermines the scale of the number of bytes.static StringCreates a formatted string for the scale that most closely represents the byteCount.units(int unitCount) Formats thebyteCountat this scale.static ScaleReturns the enum constant of this class with the specified name.static Scale[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
B
A byte. -
KB
SI scale Kilobytes bytes -
MB
SI scale Megabytes -
GB
SI Scale Gigabttes -
TB
SI Scale Terabytes -
PB
SI Scale Petabytes -
KiB
IEC Scale Kilobytes (2 ^ 10). -
MiB
IEC Scale Megabytes (2 ^ 20) -
GiB
IEC Scale Gigabytes (2 ^ 30) -
TiB
IEC Scale Terabytes (2 ^ 40) -
PiB
IEC Scale Petabytes (2 ^ 50)
-
-
Field Details
-
IEC
The International Electrotechnical Commission (IEC) standardized binary prefixes. Developed by the IEC to avoid ambiguity through their similarity to the standard metric terms. These are based on powers of 2.- See Also:
-
SI
The SI standardized prefix scales. These are the metric units, as such they are all powers of 10. -
bytes
public final long bytesThe number of bytes in a single unit of the scale.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-
format
Formats thebyteCountat this scale.- Parameters:
byteCount- the number of bytes.- Returns:
- A string representing the number of units that comprise the
byteCount.
-
units
Formats thebyteCountat this scale.- Parameters:
unitCount- the number of units at this scale.- Returns:
- A string representing the number of units at this scale.
-
asBytes
public long asBytes(double unitCount) Gets the number of bytes found in the specified number of units.- Parameters:
unitCount- the number of units.- Returns:
- the number of bytes in
unitCountunits of this scale.
-
scaleOf
Determines the scale of the number of bytes. The largest Scale for whichbyteCountrepresents at least 1 unit is returned. If no scale in the possible scales matches then bytes are returned. Negative number will returnB.- Parameters:
byteCount- the number of bytespossibleScales- the list of possible scales.- Returns:
- the first matching scale.
-
size
Creates a formatted string for the scale that most closely represents the byteCount.- Parameters:
byteCount- the number of bytes.possibleScales- the possible Scales.- Returns:
- a formatted string representation of the
byteCountin the best Scale representation. - See Also:
-
displayValue
Creates a String using the scale. if the scale is notBthen it is followed by the number of bytes within a set of parenthesis.- Parameters:
value- the number of bytes.- Returns:
- a String using the scale. if the scale is not
Bthen it is followed by the number of bytes
-