Enum Class BitDataType

java.lang.Object
java.lang.Enum<BitDataType>
net.solarnetwork.domain.BitDataType
All Implemented Interfaces:
Serializable, Comparable<BitDataType>, Constable

public enum BitDataType extends Enum<BitDataType>
An enumeration of common bit-centric data types.
Since:
1.54
Version:
1.0
Author:
matt
  • Enum Constant Details

    • Bit

      public static final BitDataType Bit
      An individual bit.
    • Boolean

      public static final BitDataType Boolean
      Boolean byte.
    • Float32

      public static final BitDataType Float32
      32-bit floating point.
    • Float64

      public static final BitDataType Float64
      64-bit floating point.
    • Int8

      public static final BitDataType Int8
      Signed 8-bit integer.
    • UInt8

      public static final BitDataType UInt8
      Unsigned 16-bit integer.
    • Int16

      public static final BitDataType Int16
      Signed 16-bit integer.
    • UInt16

      public static final BitDataType UInt16
      Unsigned 16-bit integer.
    • Int32

      public static final BitDataType Int32
      Signed 32-bit integer.
    • UInt32

      public static final BitDataType UInt32
      Unsigned 32-bit integer.
    • Int64

      public static final BitDataType Int64
      Signed 64-bit integer.
    • UInt64

      public static final BitDataType UInt64
      Unsigned 64-bit integer.
    • Integer

      public static final BitDataType Integer
      Arbitrary bit-length signed integer, where most-significant bit represents sign.
    • UnsignedInteger

      public static final BitDataType UnsignedInteger
      Arbitrary bit-length unsigned integer.
    • Bytes

      public static final BitDataType Bytes
      Raw bytes.
    • StringUtf8

      public static final BitDataType StringUtf8
      Bytes interpreted as a UTF-8 encoded string.
    • StringAscii

      public static final BitDataType StringAscii
      Bytes interpreted as an ASCII encoded string.
  • Method Details

    • values

      public static BitDataType[] 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

      public static BitDataType valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getKey

      public String 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 StringUtf8 has a variable length, while Int32 is fixed.

      Returns:
      true if the type has a variable number of bytes, false if a fixed number
    • forKey

      public static BitDataType forKey(String key)
      Get an enum instance for a key value.
      Parameters:
      key - the key
      Returns:
      the enum
      Throws:
      IllegalArgumentException - if key is not a valid value
    • getDescription

      public String getDescription()
      Get a friendly description for this data type.
      Returns:
      the description