public class BitOutputBuffer
extends java.lang.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 |
---|---|
static int |
SZ_INCR
The increment size for the buffer, 16 bytes.
|
static int |
SZ_INIT
The 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.
|
java.lang.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.
|
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.public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2014 Open Microscopy Environment