ByteSize class

ByteSize handles how byte sizes are represented.

var size = new ByteSize(1024);
Implemented types
  • Comparable

Constructors

ByteSize([num byteSize = 0])
Initialize class with the size in Bytes denoted by byteSize. [...]

Properties

Bits → int
Returns the size in Bits
read-only
Bytes → num
Returns the size in Bytes
read-only
GigaBytes → num
Returns the size in GigaBytes
read-only
KiloBytes → num
Returns the size in KiloBytes
read-only
MegaBytes → num
Returns the size in MegaBytes
read-only
PetaBytes → num
Returns the size in PetaBytes
read-only
TeraBytes → num
Returns the size in TeraBytes
read-only
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

add(ByteSize bs) ByteSize
Returns the sum of two ByteSize objects.
addBits(int value) ByteSize
Returns the sum of size in Bits and current ByteSize instance.
addBytes(num value) ByteSize
Returns the sum of size in Bytes and current ByteSize instance.
addGigaBytes(num value) ByteSize
Returns the sum of size in GigaBytes and current ByteSize instance.
addKiloBytes(num value) ByteSize
Returns the sum of size in KiloBytes and current ByteSize instance.
addMegaBytes(num value) ByteSize
Returns the sum of size in MegaBytes and current ByteSize instance.
addPetaBytes(num value) ByteSize
Returns the sum of size in PetaBytes and current ByteSize instance.
addTeraBytes(num value) ByteSize
Returns the sum of size in TeraBytes and current ByteSize instance.
compareTo(dynamic bs) → int
Returns -1, 0 or 1 when passed another ByteSize object. [...]
override
copy() ByteSize
Returns an exact copy of the ByteSize object
fromJson(Map<String, Object> entityMap) → void
Initialize ByteSize object from JSON object according to order of precedence i.e from 'b' -> 'PB', where 'b' has higher precedence to 'KB' and 'MB' has higher precedence to 'GB' and so on.
subtract(ByteSize bs) ByteSize
Returns the difference of two ByteSize objects.
toJson() → Map<String, Object>
Converts ByteSize object to JSON object
toString([String symbol = 'KB', int precision = 2, Locale locale_LANG = Locale.en_US]) → String
Returns the string representation of the ByteSize instance i.e passing the symbol, precision and or locale_LANG as arguments. [...]
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited

Operators

operator +(ByteSize bs) ByteSize
Returns the sum of two ByteSize objects.
operator -(ByteSize bs) ByteSize
Returns the difference of two ByteSize objects.
operator <(ByteSize bs) → bool
Returns if current ByteSize instance is less than another.
operator <=(ByteSize bs) → bool
Returns if current ByteSize instance is less than or equals another.
operator ==(dynamic bs) → bool
Returns if current ByteSize instance is equal to another.
override
operator >(ByteSize bs) → bool
Returns if current ByteSize instance is greater than another.
operator >=(ByteSize bs) → bool
Returns if current ByteSize instance is greater than or equals another.

Static Methods

FromBits(int value) ByteSize
Returns a ByteSize object initialized by size in Bits. [...]
FromBytes(num value) ByteSize
Returns a ByteSize object initialized by size in Bytes. [...]
FromGigaBytes(num value) ByteSize
Returns a ByteSize object initialized by size in GigaBytes. [...]
FromKiloBytes(num value) ByteSize
Returns a ByteSize object initialized by size in KiloBytes. [...]
FromMegaBytes(num value) ByteSize
Returns a ByteSize object initialized by size in MegaBytes. [...]
FromPetaBytes(num value) ByteSize
Returns a ByteSize object initialized by size in PetaBytes. [...]
FromTeraBytes(num value) ByteSize
Returns a ByteSize object initialized by size in TeraBytes. [...]
GetMaxValue() ByteSize
Returns the maximum possible ByteSize objects.
GetMinValue() ByteSize
Returns the minimum possible ByteSize objects.
Parse(String value) ByteSize
Returns a ByteSize object by parsing a string value and throws an exception if argument is incorrectly formatted. [...]
TryParse(String value) ParseOutput
Returns a ParseOutput object by parsing a string value. [...]