|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream com.healthmarketscience.rmiio.PacketInputStream com.healthmarketscience.rmiio.util.EncodingInputStream
public abstract class EncodingInputStream
InputStream which facilitates generating a stream of data on demand through
some programmatic action. Subclasses must implement the encode(int)
method, which should write some reasonable amount of data to the
OutputStream returned from createOutputStream()
(which in turn will
forward to data to the consumer of the InputStream). The OutputStream
linked to this class must only be written during a call to
encode
.
Additionally, this class provides a "packet" based read method, which returns the underlying byte[]'s (which will be approximately the size of the chunk size configured for this class), which may be more efficient in some applications.
Note, this class has no synchronization except that the close
method supports asynchronous closing.
Field Summary | |
---|---|
static int |
DEFAULT_CHUNK_SIZE
initial size of the overflow buffer used when moving data from the internal _localOStream to the _localIStream. |
Fields inherited from class com.healthmarketscience.rmiio.PacketInputStream |
---|
DEFAULT_PACKET_SIZE, EMPTY_PACKET |
Constructor Summary | |
---|---|
protected |
EncodingInputStream()
|
protected |
EncodingInputStream(int chunkSize)
|
protected |
EncodingInputStream(int chunkSize,
boolean noDelay)
|
Method Summary | |
---|---|
int |
available()
|
void |
close()
|
protected PacketOutputStream |
createOutputStream()
Creates an OutputStream linked to this InputStream which can be used to write data as requested. |
protected abstract void |
encode(int suggestedLength)
Writes some amount of data to the OutputStream linked to the EncodingInputStream calling this method. |
protected long |
encodeSkip(long len)
Skips some amount of bytes in the encoding output. |
int |
packetsAvailable()
Returns the number of full packets which can be read without blocking. |
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] buf,
int pos,
int len)
|
byte[] |
readPacket(boolean readPartial)
Gets the next "packet" from the internal buffer and returns it (if any). |
long |
skip(long len)
|
protected void |
throwIfClosed()
Throws an IOException if the stream is closed, otherwise, does nothing. |
Methods inherited from class com.healthmarketscience.rmiio.PacketInputStream |
---|
getNoDelay, getPacketSize, readPacket, readPacket |
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_CHUNK_SIZE
Constructor Detail |
---|
protected EncodingInputStream()
protected EncodingInputStream(int chunkSize)
protected EncodingInputStream(int chunkSize, boolean noDelay)
Method Detail |
---|
protected PacketOutputStream createOutputStream()
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
protected void throwIfClosed() throws IOException
IOException
public int available() throws IOException
available
in class InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public int read(byte[] buf, int pos, int len) throws IOException
read
in class InputStream
IOException
public long skip(long len) throws IOException
skip
in class InputStream
IOException
public byte[] readPacket(boolean readPartial) throws IOException
PacketInputStream
readPacket
in class PacketInputStream
readPartial
- iff false
, may block until a full packet
is read (or EOF), otherwise will return as much data
as is currently available (which may be 0).
null
if the end of
stream has been reached. if no data is available but EOF has not
been reached, the returned buffer will have length 0.
IOException
public int packetsAvailable() throws IOException
PacketInputStream
packetsAvailable
in class PacketInputStream
IOException
protected long encodeSkip(long len) throws IOException
IOException
protected abstract void encode(int suggestedLength) throws IOException
suggestedLength
- target amount of bytes to write
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |