Class Bits

java.lang.Object
org.seppiko.commons.utils.Bits

public class Bits extends Object
A Bits with byte size.
Author:
Leonard Woo
  • Constructor Summary

    Constructors
    Constructor
    Description
    Bits constructor
    Bits(Bits original)
    Initializes a newly created Bits object so that it represents the same sequence of characters as the argument.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clean bits value.
    boolean[]
    Get a bits with boolean array
    byte
    Get this bits byte
    void
    putBit(boolean value, int position)
    Put a bit with position
    void
    putByte(byte b)
    Put a byte to bit

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Bits

      public Bits()
      Bits constructor
    • Bits

      public Bits(Bits original)
      Initializes a newly created Bits object so that it represents the same sequence of characters as the argument.
      Parameters:
      original - A Bits
  • Method Details

    • putBit

      public void putBit(boolean value, int position)
      Put a bit with position
      
         0  1  2  3  4  5  6  7
       +--+--+--+--+--+--+--+--+
       |         1 byte        |
       +--+--+--+--+--+--+--+--+
       
      Parameters:
      value - bit value
      position - this bit position
    • putByte

      public void putByte(byte b)
      Put a byte to bit
      Parameters:
      b - byte
    • getBits

      public boolean[] getBits()
      Get a bits with boolean array
      Returns:
      boolean array
    • getByte

      public byte getByte()
      Get this bits byte
      Returns:
      a byte
    • clean

      public void clean()
      Clean bits value.