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()
ReadableBuffer
readableBytes
in interface ReadableBuffer
public int readUnsignedByte()
ReadableBuffer
readUnsignedByte
in interface ReadableBuffer
public int readUnsignedMedium()
ReadableBuffer
readUnsignedMedium
in interface ReadableBuffer
public int readUnsignedShort()
ReadableBuffer
readUnsignedShort
in interface ReadableBuffer
public int readInt()
ReadableBuffer
readInt
in interface ReadableBuffer
public void skipBytes(int length)
ReadableBuffer
skipBytes
in interface ReadableBuffer
public void readBytes(byte[] dest, int destOffset, int length)
ReadableBuffer
length
bytes from this buffer and writes them to the destination array.
Increments the read position by length
.readBytes
in interface ReadableBuffer
dest
- 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)
ReadableBuffer
readBytes
in interface ReadableBuffer
dest
- the destination buffer to receive the bytes.public void readBytes(OutputStream dest, int length) throws IOException
ReadableBuffer
length
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 ReadableBuffer
dest
- 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)
ReadableBuffer
length
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 ReadableBuffer
length
- the number of bytes to contain in returned Buffer.public boolean hasArray()
ReadableBuffer
hasArray
in interface ReadableBuffer
public byte[] array()
ReadableBuffer
ReadableBuffer.hasArray()
.array
in interface ReadableBuffer
public int arrayOffset()
ReadableBuffer
ReadableBuffer.hasArray()
arrayOffset
in interface ReadableBuffer
public void close()
ReadableBuffer
close
in interface ReadableBuffer
close
in interface Closeable
close
in interface AutoCloseable