Package org.apache.pdfbox.io.ccitt
Class PackedBitArray
- java.lang.Object
-
- org.apache.pdfbox.io.ccitt.PackedBitArray
-
public class PackedBitArray extends java.lang.Object
Represents an array of bits packed in a byte array of fixed size.- Version:
- $Revision$
-
-
Constructor Summary
Constructors Constructor Description PackedBitArray(int bitCount)
Constructs a new bit array.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear all bits in the array.void
clear(int offset)
Clears a bit at the given offset.void
clearBits(int offset, int length)
Clears a run of bits at the given offset.int
getBitCount()
Returns the number of bits maintained by this array.int
getByteCount()
Returns the size of the byte buffer for this array.byte[]
getData()
Returns the underlying byte buffer.void
set(int offset)
Sets a bit at the given offset.void
setBits(int offset, int length)
Sets a run of bits at the given offset to either 1.void
setBits(int offset, int length, int bit)
Sets a run of bits at the given offset to either 1 or 0.static java.lang.String
toBitString(byte data)
Converts a byte to a "binary" String of 0s and 1s.static java.lang.String
toBitString(byte[] data)
Converts a series of bytes to a "binary" String of 0s and 1s.static java.lang.String
toBitString(byte[] data, int start, int len)
Converts a series of bytes to a "binary" String of 0s and 1s.java.lang.String
toString()
-
-
-
Method Detail
-
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toBitString
public static java.lang.String toBitString(byte data)
Converts a byte to a "binary" String of 0s and 1s.- Parameters:
data
- the value to convert- Returns:
- the binary string
-
toBitString
public static java.lang.String toBitString(byte[] data)
Converts a series of bytes to a "binary" String of 0s and 1s.- Parameters:
data
- the data- Returns:
- the binary string
-
toBitString
public static java.lang.String toBitString(byte[] data, int start, int len)
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
-
-