org.apache.pdfbox.io.ccitt
Class PackedBitArray

java.lang.Object
  extended by org.apache.pdfbox.io.ccitt.PackedBitArray

public class PackedBitArray
extends Object

Represents an array of bits packed in a byte array of fixed size.

Version:
$Revision$

Constructor Summary
PackedBitArray(int bitCount)
          Constructs a new bit array.
 
Method Summary
 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 String toBitString(byte data)
          Converts a byte to a "binary" String of 0s and 1s.
static String toBitString(byte[] data)
          Converts a series of bytes to a "binary" String of 0s and 1s.
static String toBitString(byte[] data, int start, int len)
          Converts a series of bytes to a "binary" String of 0s and 1s.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PackedBitArray

public PackedBitArray(int bitCount)
Constructs a new bit array.

Parameters:
bitCount - the number of bits to maintain
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 offset
length - the number of bits to set
bit - 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 offset
length - 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 offset
length - 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 String toString()

Overrides:
toString in class Object

toBitString

public static 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 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 String toBitString(byte[] data,
                                 int start,
                                 int len)
Converts a series of bytes to a "binary" String of 0s and 1s.

Parameters:
data - the data
start - the start offset
len - the number of bytes to convert
Returns:
the binary string


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.