Uses of Enum Class
com.peterphi.std.types.StorageUnit
Packages that use StorageUnit
-
Uses of StorageUnit in com.peterphi.std.types
Fields in com.peterphi.std.types declared as StorageUnitModifier and TypeFieldDescriptionstatic final StorageUnit[]StorageUnit.BINARY_QUANTIFIERSThe range of quantifiers for binary units (bytes to terabytes (ISO: B to TiB))static final StorageUnit[]StorageUnit.COMPSCI_BINARYstatic final StorageUnit[]StorageUnit.DECIMAL_QUANTIFIERSThe range of quantifiers for ISO decimal units (bytes to terabytes (ISO: B to TB))static final StorageUnit[]StorageUnit.NETWORK_DECIMALstatic final StorageUnit[]StorageUnit.STORAGE_DECIMALMethods in com.peterphi.std.types that return StorageUnitModifier and TypeMethodDescriptionstatic StorageUnitStorageUnit.getAppropriateBinaryUnit(BigInteger amount, StorageUnit sourceUnit) Attempts to locate the most appropriate binary unit (binary units are what everyone but the ISO and the storage industry mean by "KB", "MB", etc.static StorageUnitStorageUnit.getAppropriateDecimalUnit(BigInteger amount, StorageUnit sourceUnit) Attempts to locate the most appropriate decimal unit (decimal units are what the ISO and the storage industry (but nobody else) mean by "KB", "MB", etc.static StorageUnitStorageUnit.getAppropriateUnit(BigInteger amount, StorageUnit sourceUnit, StorageUnit[] options) Attempts to locate the most appropriate of the provided units to express the provided amount in for human use (balancing precision and sensible expression)StorageSize.getUnit()The unit which this Storage Size should be expressed by defaultstatic StorageUnitStorageUnit.largest(StorageUnit unit, StorageUnit unit2) Returns the the larger unit ofunitand unit2static StorageUnitParse the non-ISO abbreviation: MiB and MB both -> MEGABYTE (which is technically a "Mebibyte")static StorageUnitParse the ISO abbreviation: (e.g.static StorageUnitStorageUnit.smallest(StorageUnit unit, StorageUnit unit2) Returns the the most diminutive unit ofunitand unit2static StorageUnitReturns the enum constant of this class with the specified name.static StorageUnit[]StorageUnit.values()Returns an array containing the constants of this enum class, in the order they are declared.Methods in com.peterphi.std.types with parameters of type StorageUnitModifier and TypeMethodDescriptionintStorageSize.compareTo(long amount, StorageUnit unit) Performs a comparison based on the number of bits represented
Since this class has a natural ordering that is inconsistent with equals, this method may return 0 whereequalswould not return0- since this compares based on bits but equals tests based on the unit+amountStorageSize.convert(StorageUnit toUnit) Convert this StorageSize to use the named unitlongStorageUnit.convert(long amount, StorageUnit unit) StorageUnit.convert(BigDecimal amount, StorageUnit unit) StorageUnit.convert(BigInteger amount, StorageUnit unit) StorageSize.getAmount(StorageUnit unit) Converts the size of this StorageSize to another unit, rounding the result to an integer
This method may result in the loss of information (due to rounding).static StorageUnitStorageUnit.getAppropriateBinaryUnit(BigInteger amount, StorageUnit sourceUnit) Attempts to locate the most appropriate binary unit (binary units are what everyone but the ISO and the storage industry mean by "KB", "MB", etc.static StorageUnitStorageUnit.getAppropriateDecimalUnit(BigInteger amount, StorageUnit sourceUnit) Attempts to locate the most appropriate decimal unit (decimal units are what the ISO and the storage industry (but nobody else) mean by "KB", "MB", etc.static StorageUnitStorageUnit.getAppropriateUnit(BigInteger amount, StorageUnit sourceUnit, StorageUnit[] options) Attempts to locate the most appropriate of the provided units to express the provided amount in for human use (balancing precision and sensible expression)StorageSize.getDecimalAmount(StorageUnit unit) Converts the size of this StorageSize to another unit, returning the result as a real number (using the BigDecimal type)
The calculations may result in minimal loss of precision, however this is unavoidable.static StorageUnitStorageUnit.largest(StorageUnit unit, StorageUnit unit2) Returns the the larger unit ofunitand unit2static StorageUnitStorageUnit.smallest(StorageUnit unit, StorageUnit unit2) Returns the the most diminutive unit ofunitand unit2StorageSize.toPlainString(StorageUnit unit) Return a String version of this size (e.g.StorageSize.toShortString(StorageUnit unit) Return a short ISO String version of this size using the provided unit (e.g.Constructors in com.peterphi.std.types with parameters of type StorageUnitModifierConstructorDescriptionStorageSize(long amount, StorageUnit unit) protectedStorageSize(StorageUnit unit, BigInteger bits) Internal constructor.StorageSize(BigDecimal amount, StorageUnit unit) Creates a new StorageSize where the value is an approximation of the provided value
Since this is an approximation some information may be lost.StorageSize(BigInteger amount, StorageUnit unit) Creates a new StorageSize where the value is equal to the provided value
If the unit is in BITS then any fractional bytes resulting from the conversion will be discarded (e.g.