Interface DataBuffer
-
- All Known Implementing Classes:
DataFileChannel
,NettyDataBuffer
,NioDataBuffer
,ReadableDataBuffer
public interface DataBuffer
This interface is a simple wrapper for the optional data that an RPCMessage may have. This allows subclasses to support different representations of the data.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
getLength()
Returns the length of the data.java.lang.Object
getNettyOutput()
Returns an object for writing to a netty channel.java.nio.ByteBuffer
getReadOnlyByteBuffer()
Returns aByteBuffer
for read-only access to the data.int
readableBytes()
void
readBytes(byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).void
readBytes(java.io.OutputStream outputStream, int length)
Transfers this buffer's data to the given stream.void
readBytes(java.nio.ByteBuffer outputBuf)
Transfers this buffer's data to the givenByteBuffer
.void
release()
Releases the underlying buffer of this DataBuffer if no longer needed.
-
-
-
Method Detail
-
getNettyOutput
java.lang.Object getNettyOutput()
Returns an object for writing to a netty channel.- Returns:
- the object to output to Netty. Must be ByteBuf or FileRegion
-
getLength
long getLength()
Returns the length of the data.- Returns:
- the length of the data in bytes
-
getReadOnlyByteBuffer
java.nio.ByteBuffer getReadOnlyByteBuffer()
Returns aByteBuffer
for read-only access to the data.- Returns:
- a read-only ByteBuffer representing the data
-
readBytes
void readBytes(byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).- Parameters:
dst
- the destinationdstIndex
- the first index of the destinationlength
- the number of bytes to transfer
-
readBytes
void readBytes(java.io.OutputStream outputStream, int length) throws java.io.IOException
Transfers this buffer's data to the given stream.- Parameters:
outputStream
- the stream to transfer data tolength
- length of the data to be transferred- Throws:
java.io.IOException
-
readBytes
void readBytes(java.nio.ByteBuffer outputBuf)
Transfers this buffer's data to the givenByteBuffer
.- Parameters:
outputBuf
- the buffer to transfer data to
-
readableBytes
int readableBytes()
- Returns:
- the number of readable bytes remaining
-
release
void release()
Releases the underlying buffer of this DataBuffer if no longer needed.
-
-