class PktHeaderBitReader extends Object
Modifier and Type | Field and Description |
---|---|
(package private) ByteArrayInputStream |
bais
The byte array that is the source of data if the PktHeaderBitReader
is instantiated with a buffer instead of a RandomAccessIO
|
(package private) int |
bbuf
The current bit buffer
|
(package private) int |
bpos
The position of the next bit to read in the bit buffer (0 means
empty, 8 full)
|
(package private) RandomAccessIO |
in
The byte based source of data
|
(package private) int |
nextbbuf
The next bit buffer, if bit stuffing occurred (i.e.
|
(package private) boolean |
usebais
Flag indicating whether the data should be read from the buffer
|
Constructor and Description |
---|
PktHeaderBitReader(ByteArrayInputStream bais)
Instantiates a 'PktHeaderBitReader' that gets the byte data from the
given source.
|
PktHeaderBitReader(RandomAccessIO in)
Instantiates a 'PktHeaderBitReader' that gets the byte data from the
given source.
|
Modifier and Type | Method and Description |
---|---|
(package private) int |
readBit()
Reads a single bit from the input.
|
(package private) int |
readBits(int n)
Reads a specified number of bits and returns them in a single
integer.
|
(package private) void |
setInput(ByteArrayInputStream bais)
Sets the underlying byte based input to the given object.
|
(package private) void |
setInput(RandomAccessIO in)
Sets the underlying byte based input to the given object.
|
(package private) void |
sync()
Synchronizes this object with the underlying byte based input.
|
RandomAccessIO in
ByteArrayInputStream bais
boolean usebais
int bbuf
int bpos
int nextbbuf
PktHeaderBitReader(RandomAccessIO in)
in
- The source of byte dataPktHeaderBitReader(ByteArrayInputStream bais)
bais
- The source of byte datafinal int readBit() throws IOException
IOException
- If an I/O error occurredEOFException
- If teh end of file has been reachedfinal int readBits(int n) throws IOException
n
- The number of bits to readIOException
- If an I/O error occurredEOFException
- If teh end of file has been reachedvoid sync()
This method should always be called when some data has been read directly from the underlying byte based input since the last call to 'readBits()' or 'readBit()' before a new call to any of those methods.
void setInput(RandomAccessIO in)
This method is equivalent to creating a new 'PktHeaderBitReader' object.
in
- The source of byte datavoid setInput(ByteArrayInputStream bais)
This method is equivalent to creating a new 'PktHeaderBitReader' object.
bais
- The source of byte dataCopyright © 2015 Open Microscopy Environment