Package io.netty.buffer
Class UnpooledUnsafeHeapByteBuf
- java.lang.Object
-
- io.netty.buffer.ByteBuf
-
- io.netty.buffer.AbstractByteBuf
-
- io.netty.buffer.AbstractReferenceCountedByteBuf
-
- io.netty.buffer.UnpooledHeapByteBuf
-
- io.netty.buffer.UnpooledUnsafeHeapByteBuf
-
- All Implemented Interfaces:
ByteBufConvertible
,ReferenceCounted
,java.lang.Comparable<ByteBuf>
public class UnpooledUnsafeHeapByteBuf extends UnpooledHeapByteBuf
Big endian Java heap buffer implementation. It is recommended to useAbstractByteBufAllocator.heapBuffer(int, int)
,Unpooled.buffer(int)
andUnpooled.wrappedBuffer(byte[])
instead of calling the constructor explicitly.
-
-
Constructor Summary
Constructors Constructor Description UnpooledUnsafeHeapByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity)
Creates a new heap buffer with a newly allocated byte array.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method 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)
protected byte[]
allocateArray(int initialCapacity)
byte
getByte(int index)
Gets a byte at the specified absoluteindex
in this buffer.int
getInt(int index)
Gets a 32-bit integer at the specified absoluteindex
in this buffer.int
getIntLE(int index)
Gets a 32-bit integer at the specified absoluteindex
in this buffer with Little Endian Byte Order.long
getLong(int index)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer.long
getLongLE(int index)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.short
getShort(int index)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer.short
getShortLE(int index)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.int
getUnsignedMedium(int index)
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer.int
getUnsignedMediumLE(int index)
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.protected SwappedByteBuf
newSwappedByteBuf()
Deprecated.ByteBuf
setByte(int index, int value)
Sets the specified byte at the specified absoluteindex
in this buffer.ByteBuf
setInt(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer.ByteBuf
setIntLE(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer with Little Endian byte order .ByteBuf
setLong(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer.ByteBuf
setLongLE(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order.ByteBuf
setMedium(int index, int value)
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer.ByteBuf
setMediumLE(int index, int value)
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer in the Little Endian Byte Order.ByteBuf
setShort(int index, int value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer.ByteBuf
setShortLE(int index, int value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer with the Little Endian Byte Order.ByteBuf
setZero(int index, int length)
Fills this buffer with NUL (0x00) starting at the specified absoluteindex
.ByteBuf
writeZero(int length)
Fills this buffer with NUL (0x00) starting at the currentwriterIndex
and increases thewriterIndex
by the specifiedlength
.-
Methods inherited from class io.netty.buffer.UnpooledHeapByteBuf
alloc, array, arrayOffset, capacity, capacity, copy, deallocate, freeArray, getBytes, getBytes, getBytes, getBytes, getBytes, getBytes, hasArray, hasMemoryAddress, internalNioBuffer, isContiguous, isDirect, memoryAddress, nioBuffer, nioBufferCount, nioBuffers, order, readBytes, readBytes, setBytes, setBytes, setBytes, setBytes, setBytes, setBytes, unwrap
-
Methods inherited from class io.netty.buffer.AbstractReferenceCountedByteBuf
refCnt, release, release, resetRefCnt, retain, retain, setRefCnt, touch, touch
-
Methods inherited from class io.netty.buffer.AbstractByteBuf
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, getMedium, getMediumLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, 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, 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, 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
-
Methods inherited from class io.netty.buffer.ByteBuf
asByteBuf, getDoubleLE, getFloatLE, maxFastWritableBytes, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
-
-
-
-
Constructor Detail
-
UnpooledUnsafeHeapByteBuf
public UnpooledUnsafeHeapByteBuf(ByteBufAllocator alloc, int initialCapacity, int maxCapacity)
Creates a new heap buffer with a newly allocated byte array.- Parameters:
initialCapacity
- the initial capacity of the underlying byte arraymaxCapacity
- the max capacity of the underlying byte array
-
-
Method Detail
-
allocateArray
protected byte[] allocateArray(int initialCapacity)
- Overrides:
allocateArray
in classUnpooledHeapByteBuf
-
getByte
public byte getByte(int index)
Description copied from class:ByteBuf
Gets a byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getByte
in classUnpooledHeapByteBuf
-
_getByte
protected byte _getByte(int index)
- Overrides:
_getByte
in classUnpooledHeapByteBuf
-
getShort
public short getShort(int index)
Description copied from class:ByteBuf
Gets a 16-bit short integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getShort
in classUnpooledHeapByteBuf
-
_getShort
protected short _getShort(int index)
- Overrides:
_getShort
in classUnpooledHeapByteBuf
-
getShortLE
public short getShortLE(int index)
Description copied from class:ByteBuf
Gets a 16-bit short integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getShortLE
in classUnpooledHeapByteBuf
-
_getShortLE
protected short _getShortLE(int index)
- Overrides:
_getShortLE
in classUnpooledHeapByteBuf
-
getUnsignedMedium
public int getUnsignedMedium(int index)
Description copied from class:ByteBuf
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getUnsignedMedium
in classUnpooledHeapByteBuf
-
_getUnsignedMedium
protected int _getUnsignedMedium(int index)
- Overrides:
_getUnsignedMedium
in classUnpooledHeapByteBuf
-
getUnsignedMediumLE
public int getUnsignedMediumLE(int index)
Description copied from class:ByteBuf
Gets an unsigned 24-bit medium integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getUnsignedMediumLE
in classUnpooledHeapByteBuf
-
_getUnsignedMediumLE
protected int _getUnsignedMediumLE(int index)
- Overrides:
_getUnsignedMediumLE
in classUnpooledHeapByteBuf
-
getInt
public int getInt(int index)
Description copied from class:ByteBuf
Gets a 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getInt
in classUnpooledHeapByteBuf
-
_getInt
protected int _getInt(int index)
- Overrides:
_getInt
in classUnpooledHeapByteBuf
-
getIntLE
public int getIntLE(int index)
Description copied from class:ByteBuf
Gets a 32-bit integer at the specified absoluteindex
in this buffer with Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getIntLE
in classUnpooledHeapByteBuf
-
_getIntLE
protected int _getIntLE(int index)
- Overrides:
_getIntLE
in classUnpooledHeapByteBuf
-
getLong
public long getLong(int index)
Description copied from class:ByteBuf
Gets a 64-bit long integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getLong
in classUnpooledHeapByteBuf
-
_getLong
protected long _getLong(int index)
- Overrides:
_getLong
in classUnpooledHeapByteBuf
-
getLongLE
public long getLongLE(int index)
Description copied from class:ByteBuf
Gets a 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
getLongLE
in classUnpooledHeapByteBuf
-
_getLongLE
protected long _getLongLE(int index)
- Overrides:
_getLongLE
in classUnpooledHeapByteBuf
-
setByte
public ByteBuf setByte(int index, int value)
Description copied from class:ByteBuf
Sets the specified byte at the specified absoluteindex
in this buffer. The 24 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setByte
in classUnpooledHeapByteBuf
-
_setByte
protected void _setByte(int index, int value)
- Overrides:
_setByte
in classUnpooledHeapByteBuf
-
setShort
public ByteBuf setShort(int index, int value)
Description copied from class:ByteBuf
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setShort
in classUnpooledHeapByteBuf
-
_setShort
protected void _setShort(int index, int value)
- Overrides:
_setShort
in classUnpooledHeapByteBuf
-
setShortLE
public ByteBuf setShortLE(int index, int value)
Description copied from class:ByteBuf
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer with the Little Endian Byte Order. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setShortLE
in classUnpooledHeapByteBuf
-
_setShortLE
protected void _setShortLE(int index, int value)
- Overrides:
_setShortLE
in classUnpooledHeapByteBuf
-
setMedium
public ByteBuf setMedium(int index, int value)
Description copied from class:ByteBuf
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer. Please note that the most significant byte is ignored in the specified value. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setMedium
in classUnpooledHeapByteBuf
-
_setMedium
protected void _setMedium(int index, int value)
- Overrides:
_setMedium
in classUnpooledHeapByteBuf
-
setMediumLE
public ByteBuf setMediumLE(int index, int value)
Description copied from class:ByteBuf
Sets the specified 24-bit medium integer at the specified absoluteindex
in this buffer in the Little Endian Byte Order. Please note that the most significant byte is ignored in the specified value. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setMediumLE
in classUnpooledHeapByteBuf
-
_setMediumLE
protected void _setMediumLE(int index, int value)
- Overrides:
_setMediumLE
in classUnpooledHeapByteBuf
-
setInt
public ByteBuf setInt(int index, int value)
Description copied from class:ByteBuf
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setInt
in classUnpooledHeapByteBuf
-
_setInt
protected void _setInt(int index, int value)
- Overrides:
_setInt
in classUnpooledHeapByteBuf
-
setIntLE
public ByteBuf setIntLE(int index, int value)
Description copied from class:ByteBuf
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer with Little Endian byte order . This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setIntLE
in classUnpooledHeapByteBuf
-
_setIntLE
protected void _setIntLE(int index, int value)
- Overrides:
_setIntLE
in classUnpooledHeapByteBuf
-
setLong
public ByteBuf setLong(int index, long value)
Description copied from class:ByteBuf
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setLong
in classUnpooledHeapByteBuf
-
_setLong
protected void _setLong(int index, long value)
- Overrides:
_setLong
in classUnpooledHeapByteBuf
-
setLongLE
public ByteBuf setLongLE(int index, long value)
Description copied from class:ByteBuf
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer in Little Endian Byte Order. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setLongLE
in classUnpooledHeapByteBuf
-
_setLongLE
protected void _setLongLE(int index, long value)
- Overrides:
_setLongLE
in classUnpooledHeapByteBuf
-
setZero
public ByteBuf setZero(int index, int length)
Description copied from class:ByteBuf
Fills this buffer with NUL (0x00) starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Overrides:
setZero
in classAbstractByteBuf
length
- the number of NULs to write to the buffer
-
writeZero
public ByteBuf writeZero(int length)
Description copied from class:ByteBuf
Fills this buffer with NUL (0x00) starting at the currentwriterIndex
and increases thewriterIndex
by the specifiedlength
. Ifthis.writableBytes
is less thanlength
,ByteBuf.ensureWritable(int)
will be called in an attempt to expand capacity to accommodate.- Overrides:
writeZero
in classAbstractByteBuf
- Parameters:
length
- the number of NULs to write to the buffer
-
newSwappedByteBuf
@Deprecated protected SwappedByteBuf newSwappedByteBuf()
Deprecated.Description copied from class:AbstractByteBuf
Creates a newSwappedByteBuf
for thisByteBuf
instance.- Overrides:
newSwappedByteBuf
in classAbstractByteBuf
-
-