public abstract class ForwardingReadableBuffer extends Object implements ReadableBuffer
ReadableBuffer.
This class just passes every operation through to the underlying buffer. Subclasses may override methods to intercept concertain operations.
| Constructor and Description |
|---|
ForwardingReadableBuffer(ReadableBuffer buf)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
array()
Gets the backing array for this buffer.
|
int |
arrayOffset()
Gets the offset in the backing array of the current read position.
|
void |
close()
Closes this buffer and releases any resources.
|
boolean |
hasArray()
Indicates whether or not this buffer exposes a backing array.
|
int |
readableBytes()
Gets the current number of readable bytes remaining in this buffer.
|
void |
readBytes(byte[] dest,
int destOffset,
int length)
Reads
length bytes from this buffer and writes them to the destination array. |
void |
readBytes(ByteBuffer dest)
Reads from this buffer until the destination's position reaches its limit, and increases the
read position by the number of the transferred bytes.
|
ReadableBuffer |
readBytes(int length)
Reads
length bytes from this buffer and returns a new Buffer containing them. |
void |
readBytes(OutputStream dest,
int length)
Reads
length bytes from this buffer and writes them to the destination stream. |
int |
readInt()
Reads a 4-byte signed integer from this buffer using big-endian byte ordering.
|
int |
readUnsignedByte()
Reads the next unsigned byte from this buffer and increments the read position by 1.
|
int |
readUnsignedMedium()
Reads a 3-byte unsigned integer from this buffer using big-endian byte ordering.
|
int |
readUnsignedShort()
Reads a 2-byte unsigned integer from this buffer using big-endian byte ordering.
|
void |
skipBytes(int length)
Increments the read position by the given length.
|
public ForwardingReadableBuffer(ReadableBuffer buf)
buf - the underlying bufferpublic int readableBytes()
ReadableBufferreadableBytes in interface ReadableBufferpublic int readUnsignedByte()
ReadableBufferreadUnsignedByte in interface ReadableBufferpublic int readUnsignedMedium()
ReadableBufferreadUnsignedMedium in interface ReadableBufferpublic int readUnsignedShort()
ReadableBufferreadUnsignedShort in interface ReadableBufferpublic int readInt()
ReadableBufferreadInt in interface ReadableBufferpublic void skipBytes(int length)
ReadableBufferskipBytes in interface ReadableBufferpublic void readBytes(byte[] dest,
int destOffset,
int length)
ReadableBufferlength bytes from this buffer and writes them to the destination array.
Increments the read position by length.readBytes in interface ReadableBufferdest - the destination array to receive the bytes.destOffset - the starting offset in the destination array.length - the number of bytes to be copied.public void readBytes(ByteBuffer dest)
ReadableBufferreadBytes in interface ReadableBufferdest - the destination buffer to receive the bytes.public void readBytes(OutputStream dest, int length) throws IOException
ReadableBufferlength bytes from this buffer and writes them to the destination stream.
Increments the read position by length. If the required bytes are not readable, throws
IndexOutOfBoundsException.readBytes in interface ReadableBufferdest - the destination stream to receive the bytes.length - the number of bytes to be copied.IOException - thrown if any error was encountered while writing to the stream.public ReadableBuffer readBytes(int length)
ReadableBufferlength bytes from this buffer and returns a new Buffer containing them. Some
implementations may return a Buffer sharing the backing memory with this buffer to prevent
copying. However, that means that the returned buffer may keep the (possibly much larger)
backing memory in use even after this buffer is closed.readBytes in interface ReadableBufferlength - the number of bytes to contain in returned Buffer.public boolean hasArray()
ReadableBufferhasArray in interface ReadableBufferpublic byte[] array()
ReadableBufferReadableBuffer.hasArray().array in interface ReadableBufferpublic int arrayOffset()
ReadableBufferReadableBuffer.hasArray()arrayOffset in interface ReadableBufferpublic void close()
ReadableBufferclose in interface ReadableBufferclose in interface Closeableclose in interface AutoCloseable