|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream seda.nbio.NonblockingInputStream seda.sandStorm.lib.util.MultiByteArrayInputStream
public class MultiByteArrayInputStream
This class allows you to treat a list of byte arrays as a single NonblockingInputStream. This is helpful for parsing data contained within network packets, where the payload for one ADU might be spread across multiple packets. This is a *nonblocking* interface; if you attempt to read data from it, and none is available, it will return immediately.
Field Summary | |
---|---|
private byte[][] |
arrays
|
private boolean |
closed
|
private int |
cur_array
|
private int |
cur_offset
|
private static boolean |
DEBUG
|
private int |
mark_array
|
private int |
mark_offset
|
private static int |
NUMARRAYS
|
private int |
push_array
|
Constructor Summary | |
---|---|
MultiByteArrayInputStream()
Create an empty MultiByteArrayInputStream. |
|
MultiByteArrayInputStream(byte[][] barr)
Create a MultiByteArrayInputStream with the given array of byte arrays. |
Method Summary | |
---|---|
void |
addArray(byte[] barr)
Add an array to this MultiByteArrayInputStream. |
int |
available()
Return the number of bytes available for reading. |
void |
clear()
Reset this input stream - clear all internal data and pointers to a fresh initialized state. |
void |
close()
Close this stream. |
private void |
expandArrays()
|
void |
mark(int readlimit)
Set the stream's mark to the current position. |
boolean |
markSupported()
Returns true, since mark() and reset() are supported. |
int |
nbRead()
Read the next byte from this stream. |
int |
numArrays()
Return the number of bytes registered. |
int |
read()
Read the next byte from this stream. |
int |
read(byte[] b)
Read data from this input stream into the given byte array starting at offset 0 for b.length bytes. |
int |
read(byte[] b,
int off,
int len)
Read data from this input stream into the given byte array starting at offset 'off' for 'len' bytes. |
void |
reset()
Returns the stream to the position of the previous mark(). |
long |
skip(long n)
Skip n bytes in this stream; returns the number of bytes actually skipped (which may be less than the number requested). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean DEBUG
private static final int NUMARRAYS
private boolean closed
private int cur_offset
private int cur_array
private byte[][] arrays
private int push_array
private int mark_array
private int mark_offset
Constructor Detail |
---|
public MultiByteArrayInputStream(byte[][] barr)
public MultiByteArrayInputStream()
Method Detail |
---|
public void addArray(byte[] barr)
private void expandArrays()
public int read() throws java.io.IOException
read
in class seda.nbio.NonblockingInputStream
java.io.IOException
public int nbRead() throws java.io.IOException
nbRead
in class seda.nbio.NonblockingInputStream
java.io.IOException
public int read(byte[] b) throws java.io.IOException
read
in class seda.nbio.NonblockingInputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class seda.nbio.NonblockingInputStream
java.io.IOException
public long skip(long n) throws java.io.IOException
skip
in class seda.nbio.NonblockingInputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class seda.nbio.NonblockingInputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class seda.nbio.NonblockingInputStream
java.io.IOException
public boolean markSupported()
markSupported
in class java.io.InputStream
public void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException
public void mark(int readlimit)
mark
in class java.io.InputStream
public int numArrays()
public void clear()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |