Package com.iab.gdpr

Class Bits


  • public class Bits
    extends Object
    • Constructor Detail

      • Bits

        public Bits​(byte[] b)
    • Method Detail

      • getBit

        public boolean getBit​(int index)
        Parameters:
        index - : the nth number bit to get from the bit string
        Returns:
        boolean bit, true if the bit is switched to 1, false otherwise
      • setBit

        public void setBit​(int index)
        Parameters:
        index - : set the nth number bit from the bit string
      • unsetBit

        public void unsetBit​(int index)
        Parameters:
        index - : unset the nth number bit from the bit string
      • getInt

        public int getInt​(int startInclusive,
                          int size)
                   throws VendorConsentException
        interprets n number of bits as a big endiant int
        Parameters:
        startInclusive - : the nth to begin interpreting from
        size - : the number of bits to interpret
        Returns:
        integer value
        Throws:
        VendorConsentException - when the bits cannot fit in an int sized field
      • setInt

        public void setInt​(int startInclusive,
                           int size,
                           int to)
                    throws VendorConsentException
        Writes an integer value into a bit array of given size
        Parameters:
        startInclusive - : the nth to begin writing to
        size - : the number of bits available to write
        to - : the integer to write out
        Throws:
        VendorConsentException - when the bits cannot fit into the provided size
      • getInstantFromEpochDeciseconds

        public Instant getInstantFromEpochDeciseconds​(int startInclusive,
                                                      int size)
                                               throws VendorConsentException
        returns an Instant derived from interpreting the given interval on the bit string as long representing the number of demiseconds from the unix epoch
        Parameters:
        startInclusive - : the bit from which to begin interpreting
        size - : the number of bits to interpret
        Returns:
        instant value
        Throws:
        VendorConsentException - when the number of bits requested cannot fit in a long
      • getSixBitString

        public String getSixBitString​(int startInclusive,
                                      int size)
                               throws VendorConsentException
        This method interprets the given interval in the bit string as a series of six bit characters, where 0=A and 26=Z
        Parameters:
        startInclusive - : the nth bit in the bitstring from which to start the interpretation
        size - : the number of bits to include in the string
        Returns:
        the string given by the above interpretation
        Throws:
        VendorConsentException - when the requested interval is not a multiple of six
      • setSixBitString

        public void setSixBitString​(int startInclusive,
                                    int size,
                                    String to)
                             throws VendorConsentException
        This method interprets characters, as 0=A and 26=Z and writes to the given interval in the bit string as a series of six bits
        Parameters:
        startInclusive - : the nth bit in the bitstring from which to start writing
        size - : the size of the bitstring
        to - : the string given by the above interpretation
        Throws:
        VendorConsentException - when the requested interval is not a multiple of six
      • toByteArray

        public byte[] toByteArray()