Package io.netty.buffer
Class ReadOnlyByteBufferBuf
- java.lang.Object
-
- io.netty.buffer.ByteBuf
-
- io.netty.buffer.AbstractByteBuf
-
- io.netty.buffer.AbstractReferenceCountedByteBuf
-
- io.netty.buffer.ReadOnlyByteBufferBuf
-
- All Implemented Interfaces:
ReferenceCounted,java.lang.Comparable<ByteBuf>
- Direct Known Subclasses:
ReadOnlyUnsafeDirectByteBuf
class ReadOnlyByteBufferBuf extends AbstractReferenceCountedByteBuf
Read-only ByteBuf which wraps a read-only ByteBuffer.
-
-
Field Summary
Fields Modifier and Type Field Description private ByteBufAllocatorallocatorprotected java.nio.ByteBufferbufferprivate java.nio.ByteBuffertmpNioBuf-
Fields inherited from class io.netty.buffer.AbstractByteBuf
checkAccessible, leakDetector, readerIndex, writerIndex
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyByteBufferBuf(ByteBufAllocator allocator, java.nio.ByteBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete 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)ByteBufAllocatoralloc()Returns theByteBufAllocatorwhich created this buffer.byte[]array()Returns the backing byte array of this buffer.intarrayOffset()Returns the offset of the first byte within the backing byte array of this buffer.intcapacity()Returns the number of bytes (octets) this buffer can contain.ByteBufcapacity(int newCapacity)Adjusts the capacity of this buffer.ByteBufcopy(int index, int length)Returns a copy of this buffer's sub-region.protected voiddeallocate()Called onceAbstractReferenceCountedByteBuf.refCnt()is equals 0.ByteBufensureWritable(int minWritableBytes)Expands the bufferByteBuf.capacity()to make sure the number of writable bytes is equal to or greater than the specified value.intensureWritable(int minWritableBytes, boolean force)Expands the bufferByteBuf.capacity()to make sure the number of writable bytes is equal to or greater than the specified value.bytegetByte(int index)Gets a byte at the specified absoluteindexin this buffer.ByteBufgetBytes(int index, byte[] dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.ByteBufgetBytes(int index, ByteBuf dst, int dstIndex, int length)Transfers this buffer's data to the specified destination starting at the specified absoluteindex.ByteBufgetBytes(int index, java.io.OutputStream out, int length)Transfers this buffer's data to the specified stream starting at the specified absoluteindex.ByteBufgetBytes(int index, java.nio.ByteBuffer dst)Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit.intgetBytes(int index, java.nio.channels.FileChannel out, long position, int length)Transfers this buffer's data starting at the specified absoluteindexto the specified channel starting at the given file position.intgetBytes(int index, java.nio.channels.GatheringByteChannel out, int length)Transfers this buffer's data to the specified channel starting at the specified absoluteindex.intgetInt(int index)Gets a 32-bit integer at the specified absoluteindexin this buffer.intgetIntLE(int index)Gets a 32-bit integer at the specified absoluteindexin this buffer with Little Endian Byte Order.longgetLong(int index)Gets a 64-bit long integer at the specified absoluteindexin this buffer.longgetLongLE(int index)Gets a 64-bit long integer at the specified absoluteindexin this buffer in Little Endian Byte Order.shortgetShort(int index)Gets a 16-bit short integer at the specified absoluteindexin this buffer.shortgetShortLE(int index)Gets a 16-bit short integer at the specified absoluteindexin this buffer in Little Endian Byte Order.intgetUnsignedMedium(int index)Gets an unsigned 24-bit medium integer at the specified absoluteindexin this buffer.intgetUnsignedMediumLE(int index)Gets an unsigned 24-bit medium integer at the specified absoluteindexin this buffer in Little Endian Byte Order.booleanhasArray()Returnstrueif and only if this buffer has a backing byte array.booleanhasMemoryAddress()Returnstrueif and only if this buffer has a reference to the low-level memory address that points to the backing data.protected java.nio.ByteBufferinternalNioBuffer()java.nio.ByteBufferinternalNioBuffer(int index, int length)Internal use only: Exposes the internal NIO buffer.booleanisContiguous()Returnstrueif thisByteBufimplementation is backed by a single memory region.booleanisDirect()Returnstrueif and only if this buffer is backed by an NIO direct buffer.booleanisReadOnly()Returnstrueif and only if this buffer is read-only.booleanisWritable()Returnstrueif and only if(this.capacity - this.writerIndex)is greater than0.booleanisWritable(int numBytes)Returnstrueif and only if this buffer has enough room to allow writing the specified number of elements.longmemoryAddress()Returns the low-level memory address that point to the first byte of ths backing data.java.nio.ByteBuffernioBuffer(int index, int length)Exposes this buffer's sub-region as an NIOByteBuffer.intnioBufferCount()Returns the maximum number of NIOByteBuffers that consist this buffer.java.nio.ByteBuffer[]nioBuffers(int index, int length)Exposes this buffer's bytes as an NIOByteBuffer'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.java.nio.ByteOrderorder()Returns the endianness of this buffer.ByteBufsetByte(int index, int value)Sets the specified byte at the specified absoluteindexin this buffer.ByteBufsetBytes(int index, byte[] src, int srcIndex, int length)Transfers the specified source array's data to this buffer starting at the specified absoluteindex.ByteBufsetBytes(int index, ByteBuf src, int srcIndex, int length)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex.intsetBytes(int index, java.io.InputStream in, int length)Transfers the content of the specified source stream to this buffer starting at the specified absoluteindex.ByteBufsetBytes(int index, java.nio.ByteBuffer src)Transfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit.intsetBytes(int index, java.nio.channels.FileChannel in, long position, int length)Transfers the content of the specified source channel starting at the given file position to this buffer starting at the specified absoluteindex.intsetBytes(int index, java.nio.channels.ScatteringByteChannel in, int length)Transfers the content of the specified source channel to this buffer starting at the specified absoluteindex.ByteBufsetInt(int index, int value)Sets the specified 32-bit integer at the specified absoluteindexin this buffer.ByteBufsetIntLE(int index, int value)Sets the specified 32-bit integer at the specified absoluteindexin this buffer with Little Endian byte order .ByteBufsetLong(int index, long value)Sets the specified 64-bit long integer at the specified absoluteindexin this buffer.ByteBufsetLongLE(int index, long value)Sets the specified 64-bit long integer at the specified absoluteindexin this buffer in Little Endian Byte Order.ByteBufsetMedium(int index, int value)Sets the specified 24-bit medium integer at the specified absoluteindexin this buffer.ByteBufsetMediumLE(int index, int value)Sets the specified 24-bit medium integer at the specified absoluteindexin this buffer in the Little Endian Byte Order.ByteBufsetShort(int index, int value)Sets the specified 16-bit short integer at the specified absoluteindexin this buffer.ByteBufsetShortLE(int index, int value)Sets the specified 16-bit short integer at the specified absoluteindexin this buffer with the Little Endian Byte Order.ByteBufunwrap()Return the underlying buffer instance if this buffer is a wrapper of another buffer.-
Methods inherited from class io.netty.buffer.AbstractReferenceCountedByteBuf
isAccessible, 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, checkIndex0, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardMarks, discardReadBytes, discardSomeReadBytes, duplicate, ensureAccessible, ensureWritable0, equals, forEachByte, forEachByte, forEachByteAsc0, forEachByteDesc, forEachByteDesc, forEachByteDesc0, getBoolean, getBytes, getBytes, getBytes, getChar, getCharSequence, getDouble, getFloat, getMedium, getMediumLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, getUnsignedShort, getUnsignedShortLE, hashCode, indexOf, isReadable, isReadable, markReaderIndex, markWriterIndex, maxCapacity, maxCapacity, maxWritableBytes, newSwappedByteBuf, nioBuffer, nioBuffers, order, readableBytes, readBoolean, readByte, readBytes, readBytes, 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, setIndex0, setZero, 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, writeZero
-
Methods inherited from class io.netty.buffer.ByteBuf
getDoubleLE, getFloatLE, maxFastWritableBytes, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLE
-
-
-
-
Field Detail
-
buffer
protected final java.nio.ByteBuffer buffer
-
allocator
private final ByteBufAllocator allocator
-
tmpNioBuf
private java.nio.ByteBuffer tmpNioBuf
-
-
Constructor Detail
-
ReadOnlyByteBufferBuf
ReadOnlyByteBufferBuf(ByteBufAllocator allocator, java.nio.ByteBuffer buffer)
-
-
Method Detail
-
deallocate
protected void deallocate()
Description copied from class:AbstractReferenceCountedByteBufCalled onceAbstractReferenceCountedByteBuf.refCnt()is equals 0.- Specified by:
deallocatein classAbstractReferenceCountedByteBuf
-
isWritable
public boolean isWritable()
Description copied from class:ByteBufReturnstrueif and only if(this.capacity - this.writerIndex)is greater than0.- Overrides:
isWritablein classAbstractByteBuf
-
isWritable
public boolean isWritable(int numBytes)
Description copied from class:ByteBufReturnstrueif and only if this buffer has enough room to allow writing the specified number of elements.- Overrides:
isWritablein classAbstractByteBuf
-
ensureWritable
public ByteBuf ensureWritable(int minWritableBytes)
Description copied from class:ByteBufExpands the bufferByteBuf.capacity()to make sure the number of writable bytes is equal to or greater than the specified value. If there are enough writable bytes in this buffer, this method returns with no side effect.- Overrides:
ensureWritablein classAbstractByteBuf- Parameters:
minWritableBytes- the expected minimum number of writable bytes- See Also:
ByteBuf.capacity(int)
-
ensureWritable
public int ensureWritable(int minWritableBytes, boolean force)Description copied from class:ByteBufExpands the bufferByteBuf.capacity()to make sure the number of writable bytes is equal to or greater than the specified value. UnlikeByteBuf.ensureWritable(int), this method returns a status code.- Overrides:
ensureWritablein classAbstractByteBuf- Parameters:
minWritableBytes- the expected minimum number of writable bytesforce- WhenByteBuf.writerIndex()+minWritableBytes>ByteBuf.maxCapacity():true- the capacity of the buffer is expanded toByteBuf.maxCapacity()false- the capacity of the buffer is unchanged
- Returns:
0if the buffer has enough writable bytes, and its capacity is unchanged.1if the buffer does not have enough bytes, and its capacity is unchanged.2if the buffer has enough writable bytes, and its capacity has been increased.3if the buffer does not have enough bytes, but its capacity has been increased to its maximum.
-
getByte
public byte getByte(int index)
Description copied from class:ByteBufGets a byte at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getBytein classAbstractByteBuf
-
_getByte
protected byte _getByte(int index)
- Specified by:
_getBytein classAbstractByteBuf
-
getShort
public short getShort(int index)
Description copied from class:ByteBufGets a 16-bit short integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getShortin classAbstractByteBuf
-
_getShort
protected short _getShort(int index)
- Specified by:
_getShortin classAbstractByteBuf
-
getShortLE
public short getShortLE(int index)
Description copied from class:ByteBufGets a 16-bit short integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getShortLEin classAbstractByteBuf
-
_getShortLE
protected short _getShortLE(int index)
- Specified by:
_getShortLEin classAbstractByteBuf
-
getUnsignedMedium
public int getUnsignedMedium(int index)
Description copied from class:ByteBufGets an unsigned 24-bit medium integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getUnsignedMediumin classAbstractByteBuf
-
_getUnsignedMedium
protected int _getUnsignedMedium(int index)
- Specified by:
_getUnsignedMediumin classAbstractByteBuf
-
getUnsignedMediumLE
public int getUnsignedMediumLE(int index)
Description copied from class:ByteBufGets an unsigned 24-bit medium integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getUnsignedMediumLEin classAbstractByteBuf
-
_getUnsignedMediumLE
protected int _getUnsignedMediumLE(int index)
- Specified by:
_getUnsignedMediumLEin classAbstractByteBuf
-
getInt
public int getInt(int index)
Description copied from class:ByteBufGets a 32-bit integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getIntin classAbstractByteBuf
-
_getInt
protected int _getInt(int index)
- Specified by:
_getIntin classAbstractByteBuf
-
getIntLE
public int getIntLE(int index)
Description copied from class:ByteBufGets a 32-bit integer at the specified absoluteindexin this buffer with Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getIntLEin classAbstractByteBuf
-
_getIntLE
protected int _getIntLE(int index)
- Specified by:
_getIntLEin classAbstractByteBuf
-
getLong
public long getLong(int index)
Description copied from class:ByteBufGets a 64-bit long integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getLongin classAbstractByteBuf
-
_getLong
protected long _getLong(int index)
- Specified by:
_getLongin classAbstractByteBuf
-
getLongLE
public long getLongLE(int index)
Description copied from class:ByteBufGets a 64-bit long integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
getLongLEin classAbstractByteBuf
-
_getLongLE
protected long _getLongLE(int index)
- Specified by:
_getLongLEin classAbstractByteBuf
-
getBytes
public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof both the source (i.e.this) and the destination.
-
getBytes
public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getBytes
public ByteBuf getBytes(int index, java.nio.ByteBuffer dst)
Description copied from class:ByteBufTransfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer while the destination'spositionwill be increased.
-
setByte
public ByteBuf setByte(int index, int value)
Description copied from class:ByteBufSets the specified byte at the specified absoluteindexin this buffer. The 24 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setBytein classAbstractByteBuf
-
_setByte
protected void _setByte(int index, int value)- Specified by:
_setBytein classAbstractByteBuf
-
setShort
public ByteBuf setShort(int index, int value)
Description copied from class:ByteBufSets the specified 16-bit short integer at the specified absoluteindexin this buffer. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setShortin classAbstractByteBuf
-
_setShort
protected void _setShort(int index, int value)- Specified by:
_setShortin classAbstractByteBuf
-
setShortLE
public ByteBuf setShortLE(int index, int value)
Description copied from class:ByteBufSets the specified 16-bit short integer at the specified absoluteindexin this buffer with the Little Endian Byte Order. The 16 high-order bits of the specified value are ignored. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setShortLEin classAbstractByteBuf
-
_setShortLE
protected void _setShortLE(int index, int value)- Specified by:
_setShortLEin classAbstractByteBuf
-
setMedium
public ByteBuf setMedium(int index, int value)
Description copied from class:ByteBufSets the specified 24-bit medium integer at the specified absoluteindexin this buffer. Please note that the most significant byte is ignored in the specified value. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setMediumin classAbstractByteBuf
-
_setMedium
protected void _setMedium(int index, int value)- Specified by:
_setMediumin classAbstractByteBuf
-
setMediumLE
public ByteBuf setMediumLE(int index, int value)
Description copied from class:ByteBufSets the specified 24-bit medium integer at the specified absoluteindexin 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 modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setMediumLEin classAbstractByteBuf
-
_setMediumLE
protected void _setMediumLE(int index, int value)- Specified by:
_setMediumLEin classAbstractByteBuf
-
setInt
public ByteBuf setInt(int index, int value)
Description copied from class:ByteBufSets the specified 32-bit integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setIntin classAbstractByteBuf
-
_setInt
protected void _setInt(int index, int value)- Specified by:
_setIntin classAbstractByteBuf
-
setIntLE
public ByteBuf setIntLE(int index, int value)
Description copied from class:ByteBufSets the specified 32-bit integer at the specified absoluteindexin this buffer with Little Endian byte order . This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setIntLEin classAbstractByteBuf
-
_setIntLE
protected void _setIntLE(int index, int value)- Specified by:
_setIntLEin classAbstractByteBuf
-
setLong
public ByteBuf setLong(int index, long value)
Description copied from class:ByteBufSets the specified 64-bit long integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setLongin classAbstractByteBuf
-
_setLong
protected void _setLong(int index, long value)- Specified by:
_setLongin classAbstractByteBuf
-
setLongLE
public ByteBuf setLongLE(int index, long value)
Description copied from class:ByteBufSets the specified 64-bit long integer at the specified absoluteindexin this buffer in Little Endian Byte Order. This method does not modifyreaderIndexorwriterIndexof this buffer.- Overrides:
setLongLEin classAbstractByteBuf
-
_setLongLE
protected void _setLongLE(int index, long value)- Specified by:
_setLongLEin classAbstractByteBuf
-
capacity
public int capacity()
Description copied from class:ByteBufReturns the number of bytes (octets) this buffer can contain.
-
capacity
public ByteBuf capacity(int newCapacity)
Description copied from class:ByteBufAdjusts the capacity of this buffer. If thenewCapacityis less than the current capacity, the content of this buffer is truncated. If thenewCapacityis greater than the current capacity, the buffer is appended with unspecified data whose length is(newCapacity - currentCapacity).
-
alloc
public ByteBufAllocator alloc()
Description copied from class:ByteBufReturns theByteBufAllocatorwhich created this buffer.
-
order
public java.nio.ByteOrder order()
Description copied from class:ByteBufReturns the endianness of this buffer.
-
unwrap
public ByteBuf unwrap()
Description copied from class:ByteBufReturn the underlying buffer instance if this buffer is a wrapper of another buffer.
-
isReadOnly
public boolean isReadOnly()
Description copied from class:ByteBufReturnstrueif and only if this buffer is read-only.- Overrides:
isReadOnlyin classAbstractByteBuf
-
isDirect
public boolean isDirect()
Description copied from class:ByteBufReturnstrueif and only if this buffer is backed by an NIO direct buffer.
-
getBytes
public ByteBuf getBytes(int index, java.io.OutputStream out, int length) throws java.io.IOException
Description copied from class:ByteBufTransfers this buffer's data to the specified stream starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getBytes
public int getBytes(int index, java.nio.channels.GatheringByteChannel out, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers this buffer's data to the specified channel starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
getBytes
public int getBytes(int index, java.nio.channels.FileChannel out, long position, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers this buffer's data starting at the specified absoluteindexto the specified channel starting at the given file position. This method does not modifyreaderIndexorwriterIndexof this buffer. This method does not modify the channel's position.- Specified by:
getBytesin classByteBufposition- the file position at which the transfer is to beginlength- the maximum number of bytes to transfer- Returns:
- the actual number of bytes written out to the specified channel
- Throws:
java.io.IOException- if the specified channel threw an exception during I/O
-
setBytes
public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof both the source (i.e.this) and the destination.
-
setBytes
public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
Description copied from class:ByteBufTransfers the specified source array's data to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public ByteBuf setBytes(int index, java.nio.ByteBuffer src)
Description copied from class:ByteBufTransfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the source buffer's position reaches its limit. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public int setBytes(int index, java.io.InputStream in, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers the content of the specified source stream to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public int setBytes(int index, java.nio.channels.ScatteringByteChannel in, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers the content of the specified source channel to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
setBytes
public int setBytes(int index, java.nio.channels.FileChannel in, long position, int length) throws java.io.IOExceptionDescription copied from class:ByteBufTransfers the content of the specified source channel starting at the given file position to this buffer starting at the specified absoluteindex. This method does not modifyreaderIndexorwriterIndexof this buffer. This method does not modify the channel's position.- Specified by:
setBytesin classByteBufposition- the file position at which the transfer is to beginlength- the maximum number of bytes to transfer- Returns:
- the actual number of bytes read in from the specified channel.
-1if the specified channel is closed. - Throws:
java.io.IOException- if the specified channel threw an exception during I/O
-
internalNioBuffer
protected final java.nio.ByteBuffer internalNioBuffer()
-
copy
public ByteBuf copy(int index, int length)
Description copied from class:ByteBufReturns a copy of this buffer's sub-region. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method does not modifyreaderIndexorwriterIndexof this buffer.
-
nioBufferCount
public int nioBufferCount()
Description copied from class:ByteBufReturns the maximum number of NIOByteBuffers that consist this buffer. Note thatByteBuf.nioBuffers()orByteBuf.nioBuffers(int, int)might return a less number ofByteBuffers.- Specified by:
nioBufferCountin classByteBuf- Returns:
-1if this buffer has no underlyingByteBuffer. the number of the underlyingByteBuffers if this buffer has at least one underlyingByteBuffer. Note that this method does not return0to avoid confusion.- See Also:
ByteBuf.nioBuffer(),ByteBuf.nioBuffer(int, int),ByteBuf.nioBuffers(),ByteBuf.nioBuffers(int, int)
-
nioBuffers
public java.nio.ByteBuffer[] nioBuffers(int index, int length)Description copied from class:ByteBufExposes this buffer's bytes as an NIOByteBuffer'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. This method does not modifyreaderIndexorwriterIndexof this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.- Specified by:
nioBuffersin classByteBuf- See Also:
ByteBuf.nioBufferCount(),ByteBuf.nioBuffer(),ByteBuf.nioBuffer(int, int)
-
nioBuffer
public java.nio.ByteBuffer nioBuffer(int index, int length)Description copied from class:ByteBufExposes this buffer's sub-region as an NIOByteBuffer. 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. This method does not modifyreaderIndexorwriterIndexof this buffer. Please note that the returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic buffer and it adjusted its capacity.- Specified by:
nioBufferin classByteBuf- See Also:
ByteBuf.nioBufferCount(),ByteBuf.nioBuffers(),ByteBuf.nioBuffers(int, int)
-
internalNioBuffer
public java.nio.ByteBuffer internalNioBuffer(int index, int length)Description copied from class:ByteBufInternal use only: Exposes the internal NIO buffer.- Specified by:
internalNioBufferin classByteBuf
-
isContiguous
public final boolean isContiguous()
Description copied from class:ByteBufReturnstrueif thisByteBufimplementation is backed by a single memory region. Composite buffer implementations must return false even if they currently hold ≤ 1 components. For buffers that returntrue, it's guaranteed that a successful call toByteBuf.discardReadBytes()will increase the value ofByteBuf.maxFastWritableBytes()by the currentreaderIndex.This method will return
falseby default, and afalsereturn value does not necessarily mean that the implementation is composite or that it is not backed by a single memory region.- Overrides:
isContiguousin classByteBuf
-
hasArray
public boolean hasArray()
Description copied from class:ByteBufReturnstrueif and only if this buffer has a backing byte array. If this method returns true, you can safely callByteBuf.array()andByteBuf.arrayOffset().
-
array
public byte[] array()
Description copied from class:ByteBufReturns the backing byte array of this buffer.
-
arrayOffset
public int arrayOffset()
Description copied from class:ByteBufReturns the offset of the first byte within the backing byte array of this buffer.- Specified by:
arrayOffsetin classByteBuf
-
hasMemoryAddress
public boolean hasMemoryAddress()
Description copied from class:ByteBufReturnstrueif and only if this buffer has a reference to the low-level memory address that points to the backing data.- Specified by:
hasMemoryAddressin classByteBuf
-
memoryAddress
public long memoryAddress()
Description copied from class:ByteBufReturns the low-level memory address that point to the first byte of ths backing data.- Specified by:
memoryAddressin classByteBuf
-
-