|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.tumba.ngram.compression.BitInput
public final class BitInput
Reads input from an underlying input stream a bit at a time. Bits
are returned as booleans, with true=1
and
false=0
.
BitOutput
Field Summary | |
---|---|
private boolean |
_endOfStream
Set to true when all bits have been read. |
private java.io.InputStream |
_in
Underlying input stream. |
private int |
_nextBitIndex
Position of next bit in the buffered byte. |
private int |
_nextByte
Buffered byte from which bits are read. |
Constructor Summary | |
---|---|
BitInput(java.io.InputStream in)
Constructs a bit input from an underlying input stream. |
Method Summary | |
---|---|
long |
available()
Returns number of bits available for reading. |
void |
close()
Closes the underlying input stream. |
boolean |
endOfStream()
Returns true if all of the available bits have been read. |
private void |
readAhead()
Reads the next byte from the input stream into _nextByte . |
boolean |
readBit()
Reads the next bit from the input stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final java.io.InputStream _in
private int _nextByte
private int _nextBitIndex
private boolean _endOfStream
Constructor Detail |
---|
public BitInput(java.io.InputStream in) throws java.io.IOException
in
- Input stream backing this bit input.
java.io.IOException
- If there is an exception reading from the specified input stream.Method Detail |
---|
public long available() throws java.io.IOException
0
or 1
.
java.io.IOException
- If there is an exception checking available bytes in the underlying input stream.public void close() throws java.io.IOException
java.io.IOException
- If there is an exception closing the underlying input stream.public boolean endOfStream()
true
if all of the available bits have been read.
true
if all of the available bits have been read.public boolean readBit() throws java.io.IOException
true
=1, false
=0.
java.io.IOException
- If there is an exception reading a byte from the underlying stream.private void readAhead() throws java.io.IOException
_nextByte
.
java.io.IOException
- If there is an IOException reading from the stream.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |