public abstract class MessageInputStream extends InputStream
Be careful this InputStream is not synchronized.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buf
The internal buffer where data is stored.
|
protected boolean |
compressedFlows |
protected int |
count
The number of valid bytes in the buffer.
|
protected static org.objectweb.util.monolog.api.Logger |
logmon
Default logger for MessageInputStream.
|
protected int |
pos
The current position in the buffer.
|
Constructor and Description |
---|
MessageInputStream()
Creates a
MessageInputStream . |
Modifier and Type | Method and Description |
---|---|
protected static org.objectweb.util.monolog.api.Logger |
getLogger()
Returns default logger for MessageInputStream.
|
abstract int |
read()
Reads the next byte of data from the input stream.
|
int |
read(byte[] b)
Reads some number of bytes from the input stream and stores them into
the buffer array
b . |
abstract int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from the input stream into
an array of bytes. |
protected abstract void |
readFully(int length)
Reads length bytes of data from the input stream.
|
protected abstract void |
readHeader()
Reads the protocol header from this output stream.
|
protected int |
readInt()
Reads an int directly from the buffer.
|
protected Message |
readMessage()
Reads the message from this input stream.
|
protected void |
readMessageHeader(Message msg)
Reads the message header data from the buffer.
|
protected short |
readShort()
Reads a short directly from the buffer.
|
available, close, mark, markSupported, reset, skip
protected byte[] buf
protected int count
The index one greater than the index of the last valid byte in the buffer.
This value is always in the range 0 through buf.length; elements buf[0] through buf[count-1] contain valid byte data.
protected int pos
buf
array.
This value is always in the range 0
through
count
. If it is less than count
, then
buf[pos]
is the next byte to be supplied as input;
if it is equal to count
, then the next read
or skip
operation will require more bytes to be read from
the contained input stream.
protected boolean compressedFlows
protected static org.objectweb.util.monolog.api.Logger logmon
protected static org.objectweb.util.monolog.api.Logger getLogger()
public abstract int read() throws IOException
int
in the range 0
to
255
. If no byte is available because the end of the stream
has been reached, the value -1
is returned. This method
blocks until input data is available, the end of the stream is detected,
or an exception is thrown.
Subclass must provide an implementation of this method.
read
in class InputStream
-1
if the end of the
stream is reached.IOException
- if an I/O error occurs.public final int read(byte[] b) throws IOException
b
. The number of bytes actually read is
returned as an integer. This method blocks until input data is
available, end of file is detected, or an exception is thrown.
The read(b)
method for class InputStream
has the same effect as: read(b, 0, b.length)
read
in class InputStream
b
- the buffer into which the data is read.-1
is there is no more data because the end of
the stream has been reached.IOException
- If the first byte cannot be read for any reason
other than the end of the file, if the input stream has been closed, or
if some other I/O error occurs.NullPointerException
- if b
is null
.public abstract int read(byte[] b, int off, int len) throws IOException
len
bytes of data from the input stream into
an array of bytes. An attempt is made to read as many as
len
bytes, but a smaller number may be read.
The number of bytes actually read is returned as an integer.
This method blocks until input data is available, end of file is detected, or an exception is thrown.
read
in class InputStream
b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is written.len
- the maximum number of bytes to read.-1
if there is no more data because the end of
the stream has been reached.IOException
- If the first byte cannot be read for any reason
other than end of file, or if the input stream has been closed, or if
some other I/O error occurs.NullPointerException
- If b
is null
.IndexOutOfBoundsException
- If off
is negative,
len
is negative, or len
is greater than
b.length - off
protected final short readShort()
protected final int readInt()
protected abstract void readHeader() throws IOException
IOException
protected final void readMessageHeader(Message msg) throws IOException
msg
- The message to complete.IOException
protected final Message readMessage() throws Exception
Exception
protected abstract void readFully(int length) throws IOException
IOException
Copyright © 2016 ScalAgent D.T.. All Rights Reserved.