Top Description Fields Constructors Methods
io.netty.buffer

public Class UnpooledDirectByteBuf

extends AbstractReferenceCountedByteBuf
Class Inheritance
Known Direct Subclasses
io.netty.buffer.UnpooledUnsafeDirectByteBuf, io.netty.buffer.ByteBufUtil.ThreadLocalDirectByteBuf, io.netty.buffer.UnpooledByteBufAllocator.InstrumentedUnpooledDirectByteBuf
Imports
io.netty.util.internal.ObjectUtil, .PlatformDependent, java.io.IOException, .InputStream, .OutputStream, java.nio.ByteBuffer, .ByteOrder, java.nio.channels.ClosedChannelException, .FileChannel, .GatheringByteChannel, .ScatteringByteChannel

A NIO ByteBuffer based buffer. It is recommended to use UnpooledByteBufAllocator#directBuffer(int, int), Unpooled#directBuffer(int) and Unpooled#wrappedBuffer(ByteBuffer) instead of calling the constructor explicitly.

Field Summary

Modifier and TypeField and Description
private final ByteBufAllocator
pack-priv ByteBuffer
private int
private boolean
private ByteBuffer

Constructor Summary

AccessConstructor and Description
public
UnpooledDirectByteBuf(ByteBufAllocator alloc, int
the initial capacity of the underlying direct buffer
initialCapacity
,
int
the maximum capacity of the underlying direct buffer
maxCapacity
)

Creates a new direct buffer.

protected
UnpooledDirectByteBuf(ByteBufAllocator alloc, ByteBuffer initialBuffer, int
the maximum capacity of the underlying direct buffer
maxCapacity
)

Creates a new direct buffer by wrapping the specified initial buffer.

pack-priv
UnpooledDirectByteBuf(ByteBufAllocator alloc, ByteBuffer initialBuffer, int maxCapacity, boolean doFree, boolean slice)

Method Summary

Modifier and TypeMethod and Description
protected byte
_getByte(int index)

Implements abstract io.netty.buffer.AbstractByteBuf._getByte.

protected int
_getInt(int index)

Implements abstract io.netty.buffer.AbstractByteBuf._getInt.

protected int
protected long
_getLong(int index)

Implements abstract io.netty.buffer.AbstractByteBuf._getLong.

protected long
protected short
protected short
protected int
protected int
protected void
_setByte(int index, int value)

Implements abstract io.netty.buffer.AbstractByteBuf._setByte.

protected void
_setInt(int index, int value)

Implements abstract io.netty.buffer.AbstractByteBuf._setInt.

protected void
_setIntLE(int index, int value)

Implements abstract io.netty.buffer.AbstractByteBuf._setIntLE.

protected void
_setLong(int index, long value)

Implements abstract io.netty.buffer.AbstractByteBuf._setLong.

protected void
_setLongLE(int index, long value)

Implements abstract io.netty.buffer.AbstractByteBuf._setLongLE.

protected void
_setMedium(int index, int value)

Implements abstract io.netty.buffer.AbstractByteBuf._setMedium.

protected void
_setMediumLE(int index, int value)

Implements abstract io.netty.buffer.AbstractByteBuf._setMediumLE.

protected void
_setShort(int index, int value)

Implements abstract io.netty.buffer.AbstractByteBuf._setShort.

protected void
_setShortLE(int index, int value)

Implements abstract io.netty.buffer.AbstractByteBuf._setShortLE.

public ByteBufAllocator
alloc()

Implements abstract io.netty.buffer.ByteBuf.alloc.

Returns the ByteBufAllocator which created this buffer.
protected ByteBuffer
allocateDirect(int initialCapacity)

Allocate a new direct ByteBuffer with the given initialCapacity.

public byte[]
array()

Implements abstract io.netty.buffer.ByteBuf.array.

Returns the backing byte array of this buffer.
public int
arrayOffset()

Implements abstract io.netty.buffer.ByteBuf.arrayOffset.

Returns the offset of the first byte within the backing byte array of this buffer.
public int
capacity()

Implements abstract io.netty.buffer.ByteBuf.capacity.

Returns the number of bytes (octets) this buffer can contain.
public ByteBuf
capacity(int newCapacity)

Implements abstract io.netty.buffer.ByteBuf.capacity.

Adjusts the capacity of this buffer.
public ByteBuf
copy(int index, int length)

Implements abstract io.netty.buffer.ByteBuf.copy.

Returns a copy of this buffer's sub-region.
protected void
protected void
freeDirect(ByteBuffer buffer)

Free a direct ByteBuffer

public byte
getByte(int index)

Overrides io.netty.buffer.AbstractByteBuf.getByte.

Gets a byte at the specified absolute index in this buffer.
public ByteBuf
getBytes(int index, ByteBuf dst, int
the first index of the destination
dstIndex
,
int
the number of bytes to transfer
length
)

Implements abstract io.netty.buffer.ByteBuf.getBytes.

Transfers this buffer's data to the specified destination starting at the specified absolute index.
public ByteBuf
getBytes(int index, byte[] dst, int
the first index of the destination
dstIndex
,
int
the number of bytes to transfer
length
)

Implements abstract io.netty.buffer.ByteBuf.getBytes.

Transfers this buffer's data to the specified destination starting at the specified absolute index.
pack-priv void
getBytes(int index, byte[] dst, int dstIndex, int length, boolean internal)

public ByteBuf
getBytes(int index, ByteBuffer dst)

Implements abstract io.netty.buffer.ByteBuf.getBytes.

Transfers this buffer's data to the specified destination starting at the specified absolute index until the destination's position reaches its limit.
pack-priv void
getBytes(int index, ByteBuffer dst, boolean internal)

public ByteBuf
getBytes(int index, OutputStream out, int
the number of bytes to transfer
length
)

Implements abstract io.netty.buffer.ByteBuf.getBytes.

Transfers this buffer's data to the specified stream starting at the specified absolute index.
pack-priv void
getBytes(int index, OutputStream out, int length, boolean internal)

public int
getBytes(int index, GatheringByteChannel out, int
the maximum number of bytes to transfer
length
)

Implements abstract io.netty.buffer.ByteBuf.getBytes.

Transfers this buffer's data to the specified channel starting at the specified absolute index.
private int
getBytes(int index, GatheringByteChannel out, int length, boolean internal)

public int
getBytes(int index, FileChannel out, long
the file position at which the transfer is to begin
position
,
int
the maximum number of bytes to transfer
length
)

Implements abstract io.netty.buffer.ByteBuf.getBytes.

Transfers this buffer's data starting at the specified absolute index to the specified channel starting at the given file position.
private int
getBytes(int index, FileChannel out, long position, int length, boolean internal)

public int
getInt(int index)

Overrides io.netty.buffer.AbstractByteBuf.getInt.

Gets a 32-bit integer at the specified absolute index in this buffer.
public long
getLong(int index)

Overrides io.netty.buffer.AbstractByteBuf.getLong.

Gets a 64-bit long integer at the specified absolute index in this buffer.
public short
getShort(int index)

Overrides io.netty.buffer.AbstractByteBuf.getShort.

Gets a 16-bit short integer at the specified absolute index in this buffer.
public int
getUnsignedMedium(int index)

Overrides io.netty.buffer.AbstractByteBuf.getUnsignedMedium.

Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer.
public boolean
hasArray()

Implements abstract io.netty.buffer.ByteBuf.hasArray.

Returns true if and only if this buffer has a backing byte array.
public boolean
hasMemoryAddress()

Implements abstract io.netty.buffer.ByteBuf.hasMemoryAddress.

Returns true if and only if this buffer has a reference to the low-level memory address that points to the backing data.
public ByteBuffer
internalNioBuffer(int index, int length)

Implements abstract io.netty.buffer.ByteBuf.internalNioBuffer.

Internal use only: Exposes the internal NIO buffer.
private ByteBuffer
public final boolean
isContiguous()

Overrides io.netty.buffer.ByteBuf.isContiguous.

Returns true if this ByteBuf implementation is backed by a single memory region.
public boolean
isDirect()

Implements abstract io.netty.buffer.ByteBuf.isDirect.

Returns true if and only if this buffer is backed by an NIO direct buffer.
public long
memoryAddress()

Implements abstract io.netty.buffer.ByteBuf.memoryAddress.

Returns the low-level memory address that point to the first byte of ths backing data.
public ByteBuffer
nioBuffer(int index, int length)

Implements abstract io.netty.buffer.ByteBuf.nioBuffer.

Exposes this buffer's sub-region as an NIO ByteBuffer.
public int
nioBufferCount()

Implements abstract io.netty.buffer.ByteBuf.nioBufferCount.

Returns the maximum number of NIO ByteBuffers that consist this buffer.
public ByteBuffer[]
nioBuffers(int index, int length)

Implements abstract io.netty.buffer.ByteBuf.nioBuffers.

Exposes this buffer's bytes as an NIO ByteBuffer's for the specified index and length The returned buffer either share or contains the copied content of this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.
public ByteOrder
order()

Implements abstract io.netty.buffer.ByteBuf.order.

Returns the endianness of this buffer.
public ByteBuf
readBytes(byte[] dst, int
the first index of the destination
dstIndex
,
int
the number of bytes to transfer
length
)

Overrides io.netty.buffer.AbstractByteBuf.readBytes.

Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
public ByteBuf
readBytes(ByteBuffer dst)

Overrides io.netty.buffer.AbstractByteBuf.readBytes.

Transfers this buffer's data to the specified destination starting at the current readerIndex until the destination's position reaches its limit, and increases the readerIndex by the number of the transferred bytes.
public ByteBuf
readBytes(OutputStream out, int
the number of bytes to transfer
length
)

Overrides io.netty.buffer.AbstractByteBuf.readBytes.

Transfers this buffer's data to the specified stream starting at the current readerIndex.
public int
readBytes(GatheringByteChannel out, int
the maximum number of bytes to transfer
length
)

Overrides io.netty.buffer.AbstractByteBuf.readBytes.

Transfers this buffer's data to the specified stream starting at the current readerIndex.
public int
readBytes(FileChannel out, long
the file position at which the transfer is to begin
position
,
int
the maximum number of bytes to transfer
length
)

Overrides io.netty.buffer.AbstractByteBuf.readBytes.

Transfers this buffer's data starting at the current readerIndex to the specified channel starting at the given file position.
public ByteBuf
setByte(int index, int value)

Overrides io.netty.buffer.AbstractByteBuf.setByte.

Sets the specified byte at the specified absolute index in this buffer.
pack-priv void
setByteBuffer(ByteBuffer buffer, boolean tryFree)

public ByteBuf
setBytes(int index, ByteBuf src, int
the first index of the source
srcIndex
,
int
the number of bytes to transfer
length
)

Implements abstract io.netty.buffer.ByteBuf.setBytes.

Transfers the specified source buffer's data to this buffer starting at the specified absolute index.
public ByteBuf
setBytes(int index, byte[] src, int srcIndex, int length)

Implements abstract io.netty.buffer.ByteBuf.setBytes.

Transfers the specified source array's data to this buffer starting at the specified absolute index.
public ByteBuf
setBytes(int index, ByteBuffer src)

Implements abstract io.netty.buffer.ByteBuf.setBytes.

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.
public int
setBytes(int index, InputStream in, int
the number of bytes to transfer
length
)

Implements abstract io.netty.buffer.ByteBuf.setBytes.

Transfers the content of the specified source stream to this buffer starting at the specified absolute index.
public int
setBytes(int index, ScatteringByteChannel in, int
the maximum number of bytes to transfer
length
)

Implements abstract io.netty.buffer.ByteBuf.setBytes.

Transfers the content of the specified source channel to this buffer starting at the specified absolute index.
public int
setBytes(int index, FileChannel in, long
the file position at which the transfer is to begin
position
,
int
the maximum number of bytes to transfer
length
)

Implements abstract io.netty.buffer.ByteBuf.setBytes.

Transfers the content of the specified source channel starting at the given file position to this buffer starting at the specified absolute index.
public ByteBuf
setInt(int index, int value)

Overrides io.netty.buffer.AbstractByteBuf.setInt.

Sets the specified 32-bit integer at the specified absolute index in this buffer.
public ByteBuf
setLong(int index, long value)

Overrides io.netty.buffer.AbstractByteBuf.setLong.

Sets the specified 64-bit long integer at the specified absolute index in this buffer.
public ByteBuf
setMedium(int index, int value)

Overrides io.netty.buffer.AbstractByteBuf.setMedium.

Sets the specified 24-bit medium integer at the specified absolute index in this buffer.
public ByteBuf
setShort(int index, int value)

Overrides io.netty.buffer.AbstractByteBuf.setShort.

Sets the specified 16-bit short integer at the specified absolute index in this buffer.
public ByteBuf
unwrap()

Implements abstract io.netty.buffer.ByteBuf.unwrap.

Return the underlying buffer instance if this buffer is a wrapper of another buffer.
Inherited from io.netty.buffer.AbstractReferenceCountedByteBuf:
isAccessiblerefCntreleasereleaseresetRefCntretainretainsetRefCnttouchtouch