Package net.solarnetwork.domain
Enum Class BitDataType
- All Implemented Interfaces:
Serializable,Comparable<BitDataType>,Constable
An enumeration of common bit-centric data types.
- Since:
- 1.54
- Version:
- 1.0
- Author:
- matt
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAn individual bit.Boolean byte.Raw bytes.32-bit floating point.64-bit floating point.Signed 16-bit integer.Signed 32-bit integer.Signed 64-bit integer.Signed 8-bit integer.Arbitrary bit-length signed integer, where most-significant bit represents sign.Bytes interpreted as an ASCII encoded string.Bytes interpreted as a UTF-8 encoded string.Unsigned 16-bit integer.Unsigned 32-bit integer.Unsigned 64-bit integer.Unsigned 16-bit integer.Arbitrary bit-length unsigned integer. -
Method Summary
Modifier and TypeMethodDescriptionstatic BitDataTypeGet an enum instance for a key value.intGet the number of bits this data type requires.intGet the number of bytes this data type requires.Get a friendly description for this data type.getKey()Get the key value for this enum.booleanTest if this type has a bit length that is not an even multiple of 8.booleanisNumber()Test if the type represents a number.booleanisSigned()Get signed flag.booleanTest if the type has a variable length.static BitDataTypeReturns the enum constant of this class with the specified name.static BitDataType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
Bit
An individual bit. -
Boolean
Boolean byte. -
Float32
32-bit floating point. -
Float64
64-bit floating point. -
Int8
Signed 8-bit integer. -
UInt8
Unsigned 16-bit integer. -
Int16
Signed 16-bit integer. -
UInt16
Unsigned 16-bit integer. -
Int32
Signed 32-bit integer. -
UInt32
Unsigned 32-bit integer. -
Int64
Signed 64-bit integer. -
UInt64
Unsigned 64-bit integer. -
Integer
Arbitrary bit-length signed integer, where most-significant bit represents sign. -
UnsignedInteger
Arbitrary bit-length unsigned integer. -
Bytes
Raw bytes. -
StringUtf8
Bytes interpreted as a UTF-8 encoded string. -
StringAscii
Bytes interpreted as an ASCII encoded string.
-
-
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
-
getKey
Get the key value for this enum.- Returns:
- the key
-
getBitLength
public int getBitLength()Get the number of bits this data type requires.- Returns:
- the number of bits, or -1 for an unknown length (for example for strings)
-
isFractionalByteLength
public boolean isFractionalByteLength()Test if this type has a bit length that is not an even multiple of 8.- Returns:
- true if
getBitLength()is not evenly divisible by 8
-
getByteLength
public int getByteLength()Get the number of bytes this data type requires.For types where
getBitLength()is not an even multiple of 8, the returned value will be rounded up to the next multiple of 8.- Returns:
- the number of bytes, or -1 for an unknown length (for example for strings)
-
isNumber
public boolean isNumber()Test if the type represents a number.- Returns:
- true if the type is a number type, false otherwise (such as bytes or a string)
-
isSigned
public boolean isSigned()Get signed flag.- Returns:
- true if the data type represents a signed number, false for unsigned (or not a number)
-
isVariableLength
public boolean isVariableLength()Test if the type has a variable length.A type like
StringUtf8has a variable length, whileInt32is fixed.- Returns:
- true if the type has a variable number of bytes, false if a fixed number
-
forKey
Get an enum instance for a key value.- Parameters:
key- the key- Returns:
- the enum
- Throws:
IllegalArgumentException- ifkeyis not a valid value
-
getDescription
Get a friendly description for this data type.- Returns:
- the description
-