ByteSize handles how byte sizes are represented.

var size = new ByteSize(1024);
Implements
  • Comparable

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.

Constructors

ByteSize([num byteSize = 0 ])

Initialize class with the size in Bytes denoted by byteSize.

ByteSize.fromJson(Map<String, Object> entityMap)

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.

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

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 ==(bs) → bool

Returns if current ByteSize instance is equal to another.

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.

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(bs) → int

Returns -1, 0 or 1 when passed another ByteSize object.

copy() ByteSize

Returns an exact copy of the ByteSize object

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.

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited