|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jj2000.j2k.entropy.decoder.ByteInputBuffer
This class provides a byte input facility from byte buffers. It is similar to the ByteArrayInputStream class, but adds the possibility to add data to the stream after the creation of the object.
Unlike the ByteArrayInputStream this class is not thread safe (i.e. no two threads can use the same object at the same time, but different objects may be used in different threads).
This class can modify the contents of the buffer given to the constructor, when the addByteArray() method is called.
InputStream
Field Summary | |
private byte[] |
buf
The byte array containing the data |
private int |
count
The index one greater than the last valid character in the input stream buffer |
private int |
pos
The index of the next character to read from the input stream buffer |
Constructor Summary | |
ByteInputBuffer(byte[] buf)
Creates a new byte array input stream that reads data from the specified byte array. |
|
ByteInputBuffer(byte[] buf,
int offset,
int length)
Creates a new byte array input stream that reads data from the specified byte array. |
Method Summary | |
void |
addByteArray(byte[] data,
int off,
int len)
Adds the specified data to the end of the byte array stream. |
int |
read()
Reads the next byte of data from this input stream. |
int |
readChecked()
Reads the next byte of data from this input stream. |
void |
setByteArray(byte[] buf,
int offset,
int length)
Sets the underlying buffer byte array to the given one, with the given offset and length. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private byte[] buf
private int count
private int pos
Constructor Detail |
public ByteInputBuffer(byte[] buf)
buf
- the input buffer.public ByteInputBuffer(byte[] buf, int offset, int length)
The byte array is not copied.
buf
- the input buffer.offset
- the offset in the buffer of the first byte to read.length
- the maximum number of bytes to read from the buffer.Method Detail |
public void setByteArray(byte[] buf, int offset, int length)
The byte array is not copied.
buf
- the input buffer. If null it is the current input buffer.offset
- the offset in the buffer of the first byte to read. If
negative it is assumed to be the byte just after the end of the current
input buffer, only permitted if 'buf' is null.length
- the maximum number of bytes to read frmo the buffer.public void addByteArray(byte[] data, int off, int len)
data
- The data to add. The data is copied.off
- The index, in data, of the first element to add to the
stream.len
- The number of elements to add to the array.public int readChecked() throws java.io.IOException
This method is not synchronized, so it is not thread safe.
java.io.EOFException
- If the end of the stream is reached.
java.io.IOException
public int read()
This method is not synchronized, so it is not thread safe.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |