Package com.iab.gdpr
Class Bits
- java.lang.Object
-
- com.iab.gdpr.Bits
-
public class Bits extends Object
-
-
Constructor Summary
Constructors Constructor Description Bits(byte[] b)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetBit(int index)InstantgetInstantFromEpochDeciseconds(int startInclusive, int size)returns anInstantderived from interpreting the given interval on the bit string as long representing the number of demiseconds from the unix epochintgetInt(int startInclusive, int size)interprets n number of bits as a big endiant intStringgetSixBitString(int startInclusive, int size)This method interprets the given interval in the bit string as a series of six bit characters, where 0=A and 26=ZvoidsetBit(int index)voidsetInstantToEpochDeciseconds(int startInclusive, int size, Instant instant)voidsetInt(int startInclusive, int size, int to)Writes an integer value into a bit array of given sizevoidsetSixBitString(int startInclusive, int size, String to)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 bitsbyte[]toByteArray()voidunsetBit(int index)
-
-
-
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 VendorConsentExceptioninterprets n number of bits as a big endiant int- Parameters:
startInclusive- : the nth to begin interpreting fromsize- : 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 VendorConsentExceptionWrites an integer value into a bit array of given size- Parameters:
startInclusive- : the nth to begin writing tosize- : the number of bits available to writeto- : 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 anInstantderived 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 interpretingsize- : the number of bits to interpret- Returns:
- instant value
- Throws:
VendorConsentException- when the number of bits requested cannot fit in a long
-
setInstantToEpochDeciseconds
public void setInstantToEpochDeciseconds(int startInclusive, int size, Instant instant) throws VendorConsentException- Throws:
VendorConsentException
-
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 interpretationsize- : 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 VendorConsentExceptionThis 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 writingsize- : the size of the bitstringto- : the string given by the above interpretation- Throws:
VendorConsentException- when the requested interval is not a multiple of six
-
toByteArray
public byte[] toByteArray()
-
-