@Deprecated public class SlicedByteBuf extends AbstractDerivedByteBuf
ByteBuf.slice() and
ByteBuf.slice(int, int) instead of calling the constructor
explicitly.| 构造器和说明 |
|---|
SlicedByteBuf(ByteBuf buffer,
int index,
int length)
已过时。
|
| 限定符和类型 | 方法和说明 |
|---|---|
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) |
ByteBufAllocator |
alloc()
Returns the
ByteBufAllocator which created this buffer. |
byte[] |
array()
Returns the backing byte array of this buffer.
|
int |
arrayOffset()
Returns the offset of the first byte within the backing byte array of
this buffer.
|
int |
capacity()
已过时。
Returns the number of bytes (octets) this buffer can contain.
|
ByteBuf |
capacity(int newCapacity)
Adjusts the capacity of this buffer.
|
ByteBuf |
copy(int index,
int length)
Returns a copy of this buffer's sub-region.
|
ByteBuf |
duplicate()
Returns a buffer which shares the whole region of this buffer.
|
int |
forEachByte(int index,
int length,
ByteProcessor processor)
Iterates over the specified area of this buffer with the specified
processor in ascending order. |
int |
forEachByteDesc(int index,
int length,
ByteProcessor processor)
Iterates over the specified area of this buffer with the specified
processor in descending order. |
byte |
getByte(int index)
Gets a byte at the specified absolute
index in this buffer. |
ByteBuf |
getBytes(int index,
byte[] dst,
int dstIndex,
int length)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index. |
ByteBuf |
getBytes(int index,
java.nio.ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at
the specified absolute
index until the destination's position
reaches its limit. |
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 |
getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length)
Transfers this buffer's data starting at the specified absolute
index
to the specified channel starting at the given file position. |
int |
getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length)
Transfers this buffer's data to the specified channel starting at the
specified absolute
index. |
ByteBuf |
getBytes(int index,
java.io.OutputStream out,
int length)
Transfers this buffer's data to the specified stream starting at the
specified absolute
index. |
java.lang.CharSequence |
getCharSequence(int index,
int length,
java.nio.charset.Charset charset)
Gets a
CharSequence with the given length at the given index. |
int |
getInt(int index)
Gets a 32-bit integer at the specified absolute
index in
this buffer. |
int |
getIntLE(int index)
Gets a 32-bit integer at the specified absolute
index in
this buffer with Little Endian Byte Order. |
long |
getLong(int index)
Gets a 64-bit long integer at the specified absolute
index in
this buffer. |
long |
getLongLE(int index)
Gets a 64-bit long integer at the specified absolute
index in
this buffer in Little Endian Byte Order. |
short |
getShort(int index)
Gets a 16-bit short integer at the specified absolute
index in
this buffer. |
short |
getShortLE(int index)
Gets a 16-bit short integer at the specified absolute
index in
this buffer in Little Endian Byte Order. |
int |
getUnsignedMedium(int index)
Gets an unsigned 24-bit medium integer at the specified absolute
index in this buffer. |
int |
getUnsignedMediumLE(int index)
Gets an unsigned 24-bit medium integer at the specified absolute
index in this buffer in Little Endian Byte Order. |
boolean |
hasArray()
Returns
true if and only if this buffer has a backing byte array. |
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. |
boolean |
isDirect()
Returns
true if and only if this buffer is backed by an
NIO direct buffer. |
long |
memoryAddress()
Returns the low-level memory address that point to the first byte of ths backing data.
|
java.nio.ByteBuffer |
nioBuffer(int index,
int length)
Exposes this buffer's sub-region as an NIO
ByteBuffer. |
int |
nioBufferCount()
Returns the maximum number of NIO
ByteBuffers that consist this buffer. |
java.nio.ByteBuffer[] |
nioBuffers(int index,
int length)
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. |
java.nio.ByteOrder |
order()
已过时。
|
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,
java.nio.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,
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 absolute
index. |
int |
setBytes(int index,
java.io.InputStream in,
int length)
Transfers the content of the specified source stream to this buffer
starting at the specified absolute
index. |
int |
setBytes(int index,
java.nio.channels.ScatteringByteChannel in,
int length)
Transfers the content of the specified source channel 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 |
setIntLE(int index,
int value)
Sets the specified 32-bit integer at the specified absolute
index in this buffer with Little Endian byte order
. |
ByteBuf |
setLong(int index,
long value)
Sets the specified 64-bit long integer at the specified absolute
index in this buffer. |
ByteBuf |
setLongLE(int index,
long value)
Sets the specified 64-bit long integer at the specified absolute
index in this buffer in Little Endian Byte Order. |
ByteBuf |
setMedium(int index,
int value)
Sets the specified 24-bit medium integer at the specified absolute
index in this buffer. |
ByteBuf |
setMediumLE(int index,
int value)
Sets the specified 24-bit medium integer at the specified absolute
index 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 absolute
index in this buffer. |
ByteBuf |
setShortLE(int index,
int value)
Sets the specified 16-bit short integer at the specified absolute
index in this buffer with the Little Endian Byte Order. |
ByteBuf |
slice(int index,
int length)
Returns a slice of this buffer's sub-region.
|
ByteBuf |
unwrap()
Return the underlying buffer instance if this buffer is a wrapper of another buffer.
|
internalNioBuffer, isContiguous, isReadOnly, refCnt, release, release, retain, retain, touch, touchadjustMarkers, asReadOnly, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkDstIndex, checkIndex, checkIndex, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardReadBytes, discardSomeReadBytes, ensureAccessible, ensureWritable, ensureWritable, equals, forEachByte, forEachByteDesc, getBoolean, getBytes, getBytes, getBytes, getChar, getDouble, getFloat, getMedium, getMediumLE, getUnsignedByte, getUnsignedInt, getUnsignedIntLE, getUnsignedShort, getUnsignedShortLE, hashCode, indexOf, isReadable, isReadable, isWritable, isWritable, 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, setZero, skipBytes, 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, writeZeroasByteBuf, getDoubleLE, getFloatLE, maxFastWritableBytes, readDoubleLE, readFloatLE, setDoubleLE, setFloatLE, writeDoubleLE, writeFloatLEpublic SlicedByteBuf(ByteBuf buffer, int index, int length)
public int capacity()
ByteBufpublic ByteBuf unwrap()
ByteBufpublic ByteBufAllocator alloc()
ByteBufByteBufAllocator which created this buffer.@Deprecated public java.nio.ByteOrder order()
ByteBufpublic boolean isDirect()
ByteBuftrue if and only if this buffer is backed by an
NIO direct buffer.public ByteBuf capacity(int newCapacity)
ByteBufnewCapacity is less than the current
capacity, the content of this buffer is truncated. If the newCapacity is greater
than the current capacity, the buffer is appended with unspecified data whose length is
(newCapacity - currentCapacity).public boolean hasArray()
ByteBuftrue if and only if this buffer has a backing byte array.
If this method returns true, you can safely call ByteBuf.array() and
ByteBuf.arrayOffset().public byte[] array()
ByteBufpublic int arrayOffset()
ByteBufarrayOffset 在类中 ByteBufpublic boolean hasMemoryAddress()
ByteBuftrue if and only if this buffer has a reference to the low-level memory address that points
to the backing data.hasMemoryAddress 在类中 ByteBufpublic long memoryAddress()
ByteBufmemoryAddress 在类中 ByteBufpublic byte getByte(int index)
ByteBufindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.getByte 在类中 AbstractByteBufprotected byte _getByte(int index)
_getByte 在类中 AbstractByteBufpublic short getShort(int index)
ByteBufindex in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.getShort 在类中 AbstractByteBufprotected short _getShort(int index)
_getShort 在类中 AbstractByteBufpublic short getShortLE(int index)
ByteBufindex in
this buffer in Little Endian Byte Order. This method does not modify
readerIndex or writerIndex of this buffer.getShortLE 在类中 AbstractByteBufprotected short _getShortLE(int index)
_getShortLE 在类中 AbstractByteBufpublic int getUnsignedMedium(int index)
ByteBufindex in this buffer. This method does not modify
readerIndex or writerIndex of this buffer.getUnsignedMedium 在类中 AbstractByteBufprotected int _getUnsignedMedium(int index)
_getUnsignedMedium 在类中 AbstractByteBufpublic int getUnsignedMediumLE(int index)
ByteBufindex in this buffer in Little Endian Byte Order.
This method does not modify readerIndex or
writerIndex of this buffer.getUnsignedMediumLE 在类中 AbstractByteBufprotected int _getUnsignedMediumLE(int index)
_getUnsignedMediumLE 在类中 AbstractByteBufpublic int getInt(int index)
ByteBufindex in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.getInt 在类中 AbstractByteBufprotected int _getInt(int index)
_getInt 在类中 AbstractByteBufpublic int getIntLE(int index)
ByteBufindex in
this buffer with Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.getIntLE 在类中 AbstractByteBufprotected int _getIntLE(int index)
_getIntLE 在类中 AbstractByteBufpublic long getLong(int index)
ByteBufindex in
this buffer. This method does not modify readerIndex or
writerIndex of this buffer.getLong 在类中 AbstractByteBufprotected long _getLong(int index)
_getLong 在类中 AbstractByteBufpublic long getLongLE(int index)
ByteBufindex in
this buffer in Little Endian Byte Order. This method does not
modify readerIndex or writerIndex of this buffer.getLongLE 在类中 AbstractByteBufprotected long _getLongLE(int index)
_getLongLE 在类中 AbstractByteBufpublic ByteBuf duplicate()
ByteBufreaderIndex or writerIndex of
this buffer.
The reader and writer marks will not be duplicated. Also be aware that this method will
NOT call ByteBuf.retain() and so the reference count will NOT be increased.
duplicate 在类中 AbstractByteBufByteBuf.slice().
However this buffer will share the capacity of the underlying buffer, and therefore allows access to all of the
underlying content if necessary.public ByteBuf copy(int index, int length)
ByteBufreaderIndex or writerIndex of
this buffer.public ByteBuf slice(int index, int length)
ByteBufreaderIndex or writerIndex of
this buffer.
Also be aware that this method will NOT call ByteBuf.retain() and so the
reference count will NOT be increased.
slice 在类中 AbstractByteBufpublic ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex
of this buffer.public ByteBuf getBytes(int index, java.nio.ByteBuffer dst)
ByteBufindex until the destination's position
reaches its limit.
This method does not modify readerIndex or writerIndex of
this buffer while the destination's position will be increased.public ByteBuf setByte(int index, int value)
ByteBufindex 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 在类中 AbstractByteBufpublic java.lang.CharSequence getCharSequence(int index,
int length,
java.nio.charset.Charset charset)
ByteBufCharSequence with the given length at the given index.getCharSequence 在类中 AbstractByteBuflength - the length to readcharset - that should be usedprotected void _setByte(int index,
int value)
_setByte 在类中 AbstractByteBufpublic ByteBuf setShort(int index, int value)
ByteBufindex 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 在类中 AbstractByteBufprotected void _setShort(int index,
int value)
_setShort 在类中 AbstractByteBufpublic ByteBuf setShortLE(int index, int value)
ByteBufindex in this buffer with the Little Endian Byte Order.
The 16 high-order bits of the specified value are ignored.
This method does not modify readerIndex or writerIndex of
this buffer.setShortLE 在类中 AbstractByteBufprotected void _setShortLE(int index,
int value)
_setShortLE 在类中 AbstractByteBufpublic ByteBuf setMedium(int index, int value)
ByteBufindex 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 在类中 AbstractByteBufprotected void _setMedium(int index,
int value)
_setMedium 在类中 AbstractByteBufpublic ByteBuf setMediumLE(int index, int value)
ByteBufindex 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 modify readerIndex or writerIndex of
this buffer.setMediumLE 在类中 AbstractByteBufprotected void _setMediumLE(int index,
int value)
_setMediumLE 在类中 AbstractByteBufpublic ByteBuf setInt(int index, int value)
ByteBufindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setInt 在类中 AbstractByteBufprotected void _setInt(int index,
int value)
_setInt 在类中 AbstractByteBufpublic ByteBuf setIntLE(int index, int value)
ByteBufindex in this buffer with Little Endian byte order
.
This method does not modify readerIndex or writerIndex of
this buffer.setIntLE 在类中 AbstractByteBufprotected void _setIntLE(int index,
int value)
_setIntLE 在类中 AbstractByteBufpublic ByteBuf setLong(int index, long value)
ByteBufindex in this buffer.
This method does not modify readerIndex or writerIndex of
this buffer.setLong 在类中 AbstractByteBufprotected void _setLong(int index,
long value)
_setLong 在类中 AbstractByteBufpublic ByteBuf setLongLE(int index, long value)
ByteBufindex in this buffer in Little Endian Byte Order.
This method does not modify readerIndex or writerIndex of
this buffer.setLongLE 在类中 AbstractByteBufprotected void _setLongLE(int index,
long value)
_setLongLE 在类中 AbstractByteBufpublic ByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length)
ByteBufindex.
This method does not modify readerIndex or writerIndex
of both the source (i.e. this) and the destination.public ByteBuf setBytes(int index, java.nio.ByteBuffer src)
ByteBufindex until the source buffer's position
reaches its limit.
This method does not modify readerIndex or writerIndex of
this buffer.public ByteBuf getBytes(int index, java.io.OutputStream out, int length) throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public int getBytes(int index,
java.nio.channels.GatheringByteChannel out,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public int getBytes(int index,
java.nio.channels.FileChannel out,
long position,
int length)
throws java.io.IOException
ByteBufindex
to the specified channel starting at the given file position.
This method does not modify readerIndex or writerIndex of
this buffer. This method does not modify the channel's position.public int setBytes(int index,
java.io.InputStream in,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public int setBytes(int index,
java.nio.channels.ScatteringByteChannel in,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer.public int setBytes(int index,
java.nio.channels.FileChannel in,
long position,
int length)
throws java.io.IOException
ByteBufindex.
This method does not modify readerIndex or writerIndex of
this buffer. This method does not modify the channel's position.setBytes 在类中 ByteBufposition - the file position at which the transfer is to beginlength - the maximum number of bytes to transfer-1 if the specified channel is closed or it reached EOF.java.io.IOException - if the specified channel threw an exception during I/Opublic int nioBufferCount()
ByteBufByteBuffers that consist this buffer. Note that ByteBuf.nioBuffers()
or ByteBuf.nioBuffers(int, int) might return a less number of ByteBuffers.nioBufferCount 在类中 ByteBuf-1 if this buffer has no underlying ByteBuffer.
the number of the underlying ByteBuffers if this buffer has at least one underlying
ByteBuffer. Note that this method does not return 0 to avoid confusion.ByteBuf.nioBuffer(),
ByteBuf.nioBuffer(int, int),
ByteBuf.nioBuffers(),
ByteBuf.nioBuffers(int, int)public java.nio.ByteBuffer nioBuffer(int index,
int length)
ByteBufByteBuffer. 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 modify readerIndex or writerIndex of 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.public java.nio.ByteBuffer[] nioBuffers(int index,
int length)
ByteBufByteBuffer'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 modify readerIndex or writerIndex of 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.public int forEachByte(int index,
int length,
ByteProcessor processor)
ByteBufprocessor in ascending order.
(i.e. index, (index + 1), .. (index + length - 1))forEachByte 在类中 AbstractByteBuf-1 if the processor iterated to or beyond the end of the specified area.
The last-visited index If the ByteProcessor.process(byte) returned false.public int forEachByteDesc(int index,
int length,
ByteProcessor processor)
ByteBufprocessor in descending order.
(i.e. (index + length - 1), (index + length - 2), ... index)forEachByteDesc 在类中 AbstractByteBuf-1 if the processor iterated to or beyond the beginning of the specified area.
The last-visited index If the ByteProcessor.process(byte) returned false.