Package org.apache.pdfbox.io.ccitt
Class PackedBitArray
java.lang.Object
org.apache.pdfbox.io.ccitt.PackedBitArray
Represents an array of bits packed in a byte array of fixed size.
- Version:
- $Revision$
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all bits in the array.voidclear(int offset) Clears a bit at the given offset.voidclearBits(int offset, int length) Clears a run of bits at the given offset.intReturns the number of bits maintained by this array.intReturns the size of the byte buffer for this array.byte[]getData()Returns the underlying byte buffer.voidset(int offset) Sets a bit at the given offset.voidsetBits(int offset, int length) Sets a run of bits at the given offset to either 1.voidsetBits(int offset, int length, int bit) Sets a run of bits at the given offset to either 1 or 0.static StringtoBitString(byte data) Converts a byte to a "binary" String of 0s and 1s.static StringtoBitString(byte[] data) Converts a series of bytes to a "binary" String of 0s and 1s.static StringtoBitString(byte[] data, int start, int len) Converts a series of bytes to a "binary" String of 0s and 1s.toString()
-
Constructor Details
-
PackedBitArray
public PackedBitArray(int bitCount) Constructs a new bit array.- Parameters:
bitCount- the number of bits to maintain
-
-
Method Details
-
set
public void set(int offset) Sets a bit at the given offset.- Parameters:
offset- the offset
-
clear
public void clear(int offset) Clears a bit at the given offset.- Parameters:
offset- the offset
-
setBits
public void setBits(int offset, int length, int bit) Sets a run of bits at the given offset to either 1 or 0.- Parameters:
offset- the offsetlength- the number of bits to setbit- 1 to set the bit, 0 to clear it
-
setBits
public void setBits(int offset, int length) Sets a run of bits at the given offset to either 1.- Parameters:
offset- the offsetlength- the number of bits to set
-
clearBits
public void clearBits(int offset, int length) Clears a run of bits at the given offset.- Parameters:
offset- the offsetlength- the number of bits to clear
-
clear
public void clear()Clear all bits in the array. -
getBitCount
public int getBitCount()Returns the number of bits maintained by this array.- Returns:
- the number of bits
-
getByteCount
public int getByteCount()Returns the size of the byte buffer for this array.- Returns:
- the size of the byte buffer
-
getData
public byte[] getData()Returns the underlying byte buffer.Note: the actual buffer is returned. If it's manipulated the content of the bit array changes.
- Returns:
- the underlying data buffer
-
toString
-
toBitString
Converts a byte to a "binary" String of 0s and 1s.- Parameters:
data- the value to convert- Returns:
- the binary string
-
toBitString
Converts a series of bytes to a "binary" String of 0s and 1s.- Parameters:
data- the data- Returns:
- the binary string
-
toBitString
Converts a series of bytes to a "binary" String of 0s and 1s.- Parameters:
data- the datastart- the start offsetlen- the number of bytes to convert- Returns:
- the binary string
-