public class BitOutputBuffer extends Object
NOTE: The methods implemented in this class are intended to be used only in writing packet heads, since a special bit stuffing procedure is used, as required for the packet heads.
| Modifier and Type | Field and Description | 
|---|---|
| (package private) int | avbitsThe number of available bits in the current byte | 
| (package private) byte[] | bufThe buffer where we store the data | 
| (package private) int | curbyteThe position of the current byte to write | 
| static int | SZ_INCRThe increment size for the buffer, 16 bytes. | 
| static int | SZ_INITThe initial size for the buffer, 32 bytes. | 
| Constructor and Description | 
|---|
| BitOutputBuffer()Creates a new BitOutputBuffer width a buffer of length
 'SZ_INIT'. | 
| Modifier and Type | Method and Description | 
|---|---|
| byte[] | getBuffer()Returns the byte buffer. | 
| int | getLength()Returns the current length of the buffer, in bytes. | 
| void | reset()Resets the buffer. | 
| byte[] | toByteArray(byte[] data)Returns the byte buffer data in a new array. | 
| String | toString()Prints information about this object for debugging purposes | 
| void | writeBit(int bit)Writes a bit to the buffer at the current position. | 
| void | writeBits(int bits,
         int n)Writes the n least significant bits of 'bits' to the buffer at the
 current position. | 
byte[] buf
int curbyte
int avbits
public static final int SZ_INCR
public static final int SZ_INIT
public BitOutputBuffer()
public void reset()
public final void writeBit(int bit)
This method is declared final to increase performance.
bit - The bit to write, 0 or 1.public final void writeBits(int bits,
             int n)
This method is declared final to increase performance.
bits - The bits to write.n - The number of LSBs in 'bits' to write.public final int getLength()
This method is declared final to increase performance.
public final byte[] getBuffer()
This method is declared final to increase performance.
public byte[] toByteArray(byte[] data)
data - If non-null this array is used to return the data, which
 mus be large enough. Otherwise a new one is created and returned.Copyright © 2016 Open Microscopy Environment