public class UnpooledUnsafeDirectByteBuf extends UnpooledDirectByteBuf
ByteBuffer
based buffer. It is recommended to use
AbstractByteBufAllocator.directBuffer(int, int)
, Unpooled.directBuffer(int)
and
Unpooled.wrappedBuffer(ByteBuffer)
instead of calling the constructor explicitly.}Modifier | Constructor and Description |
---|---|
protected |
UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc,
ByteBuffer initialBuffer,
int maxCapacity)
Creates a new direct buffer by wrapping the specified initial buffer.
|
|
UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc,
int initialCapacity,
int maxCapacity)
Creates a new direct buffer.
|
Modifier and Type | Method and Description |
---|---|
protected byte |
_getByte(int index) |
protected int |
_getInt(int index) |
protected int |
_getIntLE(int index) |
protected long |
_getLong(int index) |
protected long |
_getLongLE(int index) |
protected short |
_getShort(int index) |
protected short |
_getShortLE(int index) |
protected int |
_getUnsignedMedium(int index) |
protected int |
_getUnsignedMediumLE(int index) |
protected void |
_setByte(int index,
int value) |
protected void |
_setInt(int index,
int value) |
protected void |
_setIntLE(int index,
int value) |
protected void |
_setLong(int index,
long value) |
protected void |
_setLongLE(int index,
long value) |
protected void |
_setMedium(int index,
int value) |
protected void |
_setMediumLE(int index,
int value) |
protected void |
_setShort(int index,
int value) |
protected void |
_setShortLE(int index,
int value) |
ByteBuf |
copy(int index,
int length)
Returns a copy of this buffer's sub-region.
|
byte |
getByte(int index)
Gets a byte at the specified absolute
index in this buffer. |
ByteBuf |
getBytes(int index,
ByteBuf dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index . |
int |
getInt(int index)
Gets a 32-bit integer at the specified absolute
index in
this buffer. |
long |
getLong(int index)
Gets a 64-bit long integer at the specified absolute
index in
this buffer. |
short |
getShort(int index)
Gets a 16-bit short integer at the specified absolute
index in
this buffer. |
int |
getUnsignedMedium(int index)
Gets an unsigned 24-bit medium integer at the specified absolute
index in this buffer. |
boolean |
hasMemoryAddress()
Returns
true if and only if this buffer has a reference to the low-level memory address that points
to the backing data. |
long |
memoryAddress()
Returns the low-level memory address that point to the first byte of ths backing data.
|
protected SwappedByteBuf |
newSwappedByteBuf()
Creates a new
SwappedByteBuf for this ByteBuf instance. |
ByteBuf |
setByte(int index,
int value)
Sets the specified byte at the specified absolute
index in this
buffer. |
ByteBuf |
setBytes(int index,
byte[] src,
int srcIndex,
int length)
Transfers the specified source array's data to this buffer starting at
the specified absolute
index . |
ByteBuf |
setBytes(int index,
ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index until the source buffer's position
reaches its limit. |
ByteBuf |
setBytes(int index,
ByteBuf src,
int srcIndex,
int length)
Transfers the specified source buffer's data to this buffer starting at
the specified absolute
index . |
int |
setBytes(int index,
InputStream in,
int length)
Transfers the content of the specified source stream to this buffer
starting at the specified absolute
index . |
ByteBuf |
setInt(int index,
int value)
Sets the specified 32-bit integer at the specified absolute
index in this buffer. |
ByteBuf |
setLong(int index,
long value)
Sets the specified 64-bit long integer at the specified absolute
index in this buffer. |
ByteBuf |
setMedium(int index,
int value)
Sets the specified 24-bit medium integer at the specified absolute
index in this buffer. |
ByteBuf |
setShort(int index,
int value)
Sets the specified 16-bit short integer at the specified absolute
index in this buffer. |
ByteBuf |
setZero(int index,
int length)
Fills this buffer with NUL (0x00) starting at the specified
absolute
index . |
ByteBuf |
writeZero(int length)
Fills this buffer with NUL (0x00) starting at the current
writerIndex and increases the writerIndex by the
specified length . |
alloc, allocateDirect, array, arrayOffset, capacity, capacity, deallocate, freeDirect, getBytes, getBytes, getBytes, getBytes, getBytes, hasArray, internalNioBuffer, isContiguous, isDirect, nioBuffer, nioBufferCount, nioBuffers, order, readBytes, readBytes, readBytes, readBytes, readBytes, setBytes, setBytes, unwrap
refCnt, release, release, resetRefCnt, retain, retain, setRefCnt, touch, touch
adjustMarkers, asReadOnly, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkDstIndex, checkIndex, checkIndex, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardReadBytes, discardSomeReadBytes, duplicate, ensureAccessible, ensureWritable, ensureWritable, equals, forEachByte, forEachByte, forEachByteDesc, forEachByteDesc, getBoolean, getBytes, getBytes, getBytes, getChar, getCharSequence, getDouble, getFloat, getIntLE, getLongLE, getMedium, getMediumLE, getShortLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, getUnsignedMediumLE, getUnsignedShort, getUnsignedShortLE, hashCode, indexOf, isReadable, isReadable, isReadOnly, isWritable, isWritable, markReaderIndex, markWriterIndex, maxCapacity, maxCapacity, maxWritableBytes, nioBuffer, nioBuffers, order, readableBytes, readBoolean, readByte, readBytes, readBytes, readBytes, readBytes, readBytes, readChar, readCharSequence, readDouble, readerIndex, readerIndex, readFloat, readInt, readIntLE, readLong, readLongLE, readMedium, readMediumLE, readRetainedSlice, readShort, readShortLE, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedIntLE, readUnsignedMedium, readUnsignedMediumLE, readUnsignedShort, readUnsignedShortLE, resetReaderIndex, resetWriterIndex, retainedDuplicate, retainedSlice, retainedSlice, setBoolean, setBytes, setBytes, setBytes, setChar, setCharSequence, setDouble, setFloat, setIndex, setIntLE, setLongLE, setMediumLE, setShortLE, skipBytes, slice, slice, toString, toString, toString, trimIndicesToCapacity, writableBytes, writeBoolean, writeByte, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeChar, writeCharSequence, writeDouble, writeFloat, writeInt, writeIntLE, writeLong, writeLongLE, writeMedium, writeMediumLE, writerIndex, writerIndex, writeShort, writeShortLE
asByteBuf, getDoubleLE, getFloatLE, maxFastWritableBytes, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
public UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity)
initialCapacity
- the initial capacity of the underlying direct buffermaxCapacity
- the maximum capacity of the underlying direct bufferprotected UnpooledUnsafeDirectByteBuf(ByteBufAllocator alloc, ByteBuffer initialBuffer, int maxCapacity)
maxCapacity
- the maximum capacity of the underlying direct bufferpublic boolean hasMemoryAddress()
ByteBuf
true
if and only if this buffer has a reference to the low-level memory address that points
to the backing data.hasMemoryAddress
in class UnpooledDirectByteBuf
public long memoryAddress()
ByteBuf
memoryAddress
in class UnpooledDirectByteBuf
public byte getByte(int index)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.getByte
in class UnpooledDirectByteBuf
protected byte _getByte(int index)
_getByte
in class UnpooledDirectByteBuf
public short getShort(int index)
ByteBuf
index
in
this buffer. This method does not modify readerIndex
or
writerIndex
of this buffer.getShort
in class UnpooledDirectByteBuf
protected short _getShort(int index)
_getShort
in class UnpooledDirectByteBuf
protected short _getShortLE(int index)
_getShortLE
in class UnpooledDirectByteBuf
public int getUnsignedMedium(int index)
ByteBuf
index
in this buffer. This method does not modify
readerIndex
or writerIndex
of this buffer.getUnsignedMedium
in class UnpooledDirectByteBuf
protected int _getUnsignedMedium(int index)
_getUnsignedMedium
in class UnpooledDirectByteBuf
protected int _getUnsignedMediumLE(int index)
_getUnsignedMediumLE
in class UnpooledDirectByteBuf
public int getInt(int index)
ByteBuf
index
in
this buffer. This method does not modify readerIndex
or
writerIndex
of this buffer.getInt
in class UnpooledDirectByteBuf
protected int _getInt(int index)
_getInt
in class UnpooledDirectByteBuf
protected int _getIntLE(int index)
_getIntLE
in class UnpooledDirectByteBuf
public long getLong(int index)
ByteBuf
index
in
this buffer. This method does not modify readerIndex
or
writerIndex
of this buffer.getLong
in class UnpooledDirectByteBuf
protected long _getLong(int index)
_getLong
in class UnpooledDirectByteBuf
protected long _getLongLE(int index)
_getLongLE
in class UnpooledDirectByteBuf
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of both the source (i.e. this
) and the destination.getBytes
in class UnpooledDirectByteBuf
dstIndex
- the first index of the destinationlength
- the number of bytes to transferpublic ByteBuf setByte(int index, int value)
ByteBuf
index
in this
buffer. The 24 high-order bits of the specified value are ignored.
This method does not modify readerIndex
or writerIndex
of
this buffer.setByte
in class UnpooledDirectByteBuf
protected void _setByte(int index, int value)
_setByte
in class UnpooledDirectByteBuf
public ByteBuf setShort(int index, int value)
ByteBuf
index
in this buffer. The 16 high-order bits of the specified
value are ignored.
This method does not modify readerIndex
or writerIndex
of
this buffer.setShort
in class UnpooledDirectByteBuf
protected void _setShort(int index, int value)
_setShort
in class UnpooledDirectByteBuf
protected void _setShortLE(int index, int value)
_setShortLE
in class UnpooledDirectByteBuf
public ByteBuf setMedium(int index, int value)
ByteBuf
index
in this buffer. Please note that the most significant
byte is ignored in the specified value.
This method does not modify readerIndex
or writerIndex
of
this buffer.setMedium
in class UnpooledDirectByteBuf
protected void _setMedium(int index, int value)
_setMedium
in class UnpooledDirectByteBuf
protected void _setMediumLE(int index, int value)
_setMediumLE
in class UnpooledDirectByteBuf
public ByteBuf setInt(int index, int value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setInt
in class UnpooledDirectByteBuf
protected void _setInt(int index, int value)
_setInt
in class UnpooledDirectByteBuf
protected void _setIntLE(int index, int value)
_setIntLE
in class UnpooledDirectByteBuf
public ByteBuf setLong(int index, long value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setLong
in class UnpooledDirectByteBuf
protected void _setLong(int index, long value)
_setLong
in class UnpooledDirectByteBuf
protected void _setLongLE(int index, long value)
_setLongLE
in class UnpooledDirectByteBuf
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of both the source (i.e. this
) and the destination.setBytes
in class UnpooledDirectByteBuf
srcIndex
- the first index of the sourcelength
- the number of bytes to transferpublic ByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.setBytes
in class UnpooledDirectByteBuf
public ByteBuf setBytes(int index, ByteBuffer src)
ByteBuf
index
until the source buffer's position
reaches its limit.
This method does not modify readerIndex
or writerIndex
of
this buffer.setBytes
in class UnpooledDirectByteBuf
public int setBytes(int index, InputStream in, int length) throws IOException
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.setBytes
in class UnpooledDirectByteBuf
length
- the number of bytes to transfer-1
if the specified InputStream
reached EOF.IOException
- if the specified stream threw an exception during I/Opublic ByteBuf copy(int index, int length)
ByteBuf
readerIndex
or writerIndex
of
this buffer.copy
in class UnpooledDirectByteBuf
protected SwappedByteBuf newSwappedByteBuf()
AbstractByteBuf
SwappedByteBuf
for this ByteBuf
instance.newSwappedByteBuf
in class AbstractByteBuf
public ByteBuf setZero(int index, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.setZero
in class AbstractByteBuf
length
- the number of NULs to write to the bufferpublic ByteBuf writeZero(int length)
ByteBuf
writerIndex
and increases the writerIndex
by the
specified length
.
If this.writableBytes
is less than length
, ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.writeZero
in class AbstractByteBuf
length
- the number of NULs to write to the bufferCopyright © 2008–2024 The Netty Project. All rights reserved.