|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Objectjava.lang.Enum<SizeUnit>
org.opends.server.admin.SizeUnit
public enum SizeUnit
This enumeration defines various memory size units.
Enum Constant Summary | |
---|---|
BYTES
A byte unit. |
|
GIBI_BYTES
A gibi-byte unit. |
|
GIGA_BYTES
A giga-byte unit. |
|
KIBI_BYTES
A kibi-byte unit. |
|
KILO_BYTES
A kilo-byte unit. |
|
MEBI_BYTES
A mebi-byte unit. |
|
MEGA_BYTES
A mega-byte unit. |
|
TEBI_BYTES
A tebi-byte unit. |
|
TERA_BYTES
A tera-byte unit. |
Method Summary | |
---|---|
double |
fromBytes(long amount)
Converts the specified size in bytes to this unit. |
static SizeUnit |
getBestFitUnit(long bytes)
Gets the best-fit unit for the specified number of bytes. |
static SizeUnit |
getBestFitUnitExact(long bytes)
Gets the best-fit unit for the specified number of bytes which can represent the provided value using an integral value. |
java.lang.String |
getLongName()
Get the long name of this unit. |
java.lang.String |
getShortName()
Get the abbreviated name of this unit. |
long |
getSize()
Get the number of bytes that this unit represents. |
static SizeUnit |
getUnit(java.lang.String s)
Get the unit corresponding to the provided unit name. |
static long |
parseValue(java.lang.String s)
Parse the provided size string and return its equivalent size in bytes. |
static long |
parseValue(java.lang.String s,
SizeUnit defaultUnit)
Parse the provided size string and return its equivalent size in bytes. |
long |
toBytes(double amount)
Converts the specified size in this unit to bytes. |
java.lang.String |
toString()
|
static SizeUnit |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. |
static SizeUnit[] |
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, valueOf |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
public static final SizeUnit BYTES
public static final SizeUnit GIBI_BYTES
public static final SizeUnit GIGA_BYTES
public static final SizeUnit KIBI_BYTES
public static final SizeUnit KILO_BYTES
public static final SizeUnit MEBI_BYTES
public static final SizeUnit MEGA_BYTES
public static final SizeUnit TEBI_BYTES
public static final SizeUnit TERA_BYTES
Method Detail |
---|
public static SizeUnit[] values()
for (SizeUnit c : SizeUnit.values()) System.out.println(c);
public static SizeUnit valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.
java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified name
java.lang.NullPointerException
- if the argument is nullpublic static SizeUnit getBestFitUnit(long bytes) throws java.lang.IllegalArgumentException
BYTES
unit is
always returned. For example:
getBestFitUnit(0) // BYTES getBestFitUnit(999) // BYTES getBestFitUnit(1000) // KILO_BYTES getBestFitUnit(1024) // KIBI_BYTES getBestFitUnit(1025) // KILO_BYTES getBestFitUnit(999999) // KILO_BYTES getBestFitUnit(1000000) // MEGA_BYTES
bytes
- The number of bytes.
java.lang.IllegalArgumentException
- If bytes
is negative.getBestFitUnitExact(long)
public static SizeUnit getBestFitUnitExact(long bytes) throws java.lang.IllegalArgumentException
BYTES
unit is always returned.
For example:
getBestFitUnitExact(0) // BYTES getBestFitUnitExact(999) // BYTES getBestFitUnitExact(1000) // KILO_BYTES getBestFitUnitExact(1024) // KIBI_BYTES getBestFitUnitExact(1025) // BYTES getBestFitUnitExact(999999) // BYTES getBestFitUnitExact(1000000) // MEGA_BYTES
bytes
- The number of bytes.
java.lang.IllegalArgumentException
- If bytes
is negative.getBestFitUnit(long)
public static SizeUnit getUnit(java.lang.String s) throws java.lang.IllegalArgumentException
s
- The name of the unit. Can be the abbreviated or long
name and can contain white space and mixed case
characters.
java.lang.IllegalArgumentException
- If the provided name did not correspond to a known
memory size unit.public static long parseValue(java.lang.String s) throws java.lang.NumberFormatException
s
- The size string to be parsed.
java.lang.NumberFormatException
- If the provided size string could not be parsed.public static long parseValue(java.lang.String s, SizeUnit defaultUnit) throws java.lang.NumberFormatException
s
- The size string to be parsed.defaultUnit
- The default unit to use if there is no unit specified in
the size string, or null
if the string
must always contain a unit.
java.lang.NumberFormatException
- If the provided size string could not be parsed.public double fromBytes(long amount)
amount
- The size in bytes.
public java.lang.String getLongName()
public java.lang.String getShortName()
public long getSize()
public long toBytes(double amount) throws java.lang.NumberFormatException
amount
- The size as a quantity of this unit.
java.lang.NumberFormatException
- If the provided size exceeded long.MAX_VALUE.public java.lang.String toString()
This implementation returns the abbreviated name of this size unit.
toString
in class java.lang.Enum<SizeUnit>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |