Class JBBPFieldBit

java.lang.Object
com.igormaznitsa.jbbp.model.JBBPAbstractField
com.igormaznitsa.jbbp.model.JBBPFieldBit
All Implemented Interfaces:
BitEntity, JBBPInvertableBitOrder, JBBPNamedField, JBBPNumericField, Serializable

public final class JBBPFieldBit extends JBBPAbstractField implements JBBPNumericField, BitEntity
Describes a bit field.
Since:
1.0
See Also:
  • Constructor Details

    • JBBPFieldBit

      public JBBPFieldBit(JBBPNamedFieldInfo name, int value, JBBPBitNumber bitNumber)
      The Constructor.
      Parameters:
      name - a field name info, it can be null.
      value - the field value
      bitNumber - number of valuable bits in the value, must not be null
  • Method Details

    • reverseBits

      public static long reverseBits(byte value, JBBPBitNumber bits)
      Get the reversed bit representation of the value.
      Parameters:
      value - the value to be reversed
      bits - number of bits to be reversed, must not be null
      Returns:
      the reversed value
    • getBitWidth

      public JBBPBitNumber getBitWidth()
      Get number of valuable bits in the value. It plays informative role and doesn't play role during numeric value getting.
      Specified by:
      getBitWidth in interface BitEntity
      Returns:
      the number of valuable bits in the value.
    • getAsDouble

      public double getAsDouble()
      Description copied from interface: JBBPNumericField
      Get the field value as double.
      Specified by:
      getAsDouble in interface JBBPNumericField
      Returns:
      the field value as double
    • getAsFloat

      public float getAsFloat()
      Description copied from interface: JBBPNumericField
      Get the field value as float.
      Specified by:
      getAsFloat in interface JBBPNumericField
      Returns:
      the field value as float
    • getAsInt

      public int getAsInt()
      Description copied from interface: JBBPNumericField
      Get the field value as integer.
      Specified by:
      getAsInt in interface JBBPNumericField
      Returns:
      the field value as integer
    • getAsLong

      public long getAsLong()
      Description copied from interface: JBBPNumericField
      Get the field value as long
      Specified by:
      getAsLong in interface JBBPNumericField
      Returns:
      the field value as long
    • getAsBool

      public boolean getAsBool()
      Description copied from interface: JBBPNumericField
      Get the field value as boolean, usually if the value is 0 then false, true otherwise.
      Specified by:
      getAsBool in interface JBBPNumericField
      Returns:
      the field value as boolean
    • getAsInvertedBitOrder

      public long getAsInvertedBitOrder()
      Description copied from interface: JBBPInvertableBitOrder
      Get the value in inverted bit order.
      Specified by:
      getAsInvertedBitOrder in interface JBBPInvertableBitOrder
      Returns:
      the value in inverted bit order
    • getTypeAsString

      public String getTypeAsString()
      Description copied from class: JBBPAbstractField
      Get the field type in string representation.
      Specified by:
      getTypeAsString in class JBBPAbstractField
      Returns:
      the string representation of field type, like 'int', 'long', 'bool [123]'