@Deprecated public class ReadOnlyByteBuf extends AbstractDerivedByteBuf
Unpooled.unmodifiableBuffer(ByteBuf)
instead of calling the constructor explicitly.构造器和说明 |
---|
ReadOnlyByteBuf(ByteBuf buffer)
已过时。
|
限定符和类型 | 方法和说明 |
---|---|
protected byte |
_getByte(int index)
已过时。
|
protected int |
_getInt(int index)
已过时。
|
protected long |
_getLong(int index)
已过时。
|
protected short |
_getShort(int index)
已过时。
|
protected int |
_getUnsignedMedium(int index)
已过时。
|
protected void |
_setByte(int index,
int value)
已过时。
|
protected void |
_setInt(int index,
int value)
已过时。
|
protected void |
_setLong(int index,
long value)
已过时。
|
protected void |
_setMedium(int index,
int value)
已过时。
|
protected void |
_setShort(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 |
discardReadBytes()
已过时。
Discards the bytes between the 0th index and
readerIndex . |
ByteBuf |
duplicate()
已过时。
Returns a buffer which shares the whole region of this buffer.
|
ByteBuf |
ensureWritable(int minWritableBytes)
已过时。
Makes sure the number of the writable bytes
is equal to or greater than the specified value.
|
int |
ensureWritable(int minWritableBytes,
boolean force)
已过时。
Tries to make sure the number of the writable bytes
is equal to or greater than the specified value.
|
int |
forEachByte(int index,
int length,
ByteBufProcessor processor)
已过时。
Iterates over the specified area of this buffer with the specified
processor in ascending order. |
int |
forEachByteDesc(int index,
int length,
ByteBufProcessor 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.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 . |
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 |
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. |
boolean |
isWritable()
已过时。
Returns
true
if and only if (this.capacity - this.writerIndex) is greater
than 0 . |
boolean |
isWritable(int numBytes)
已过时。
Returns
true if and only if this buffer has enough room to allow writing the specified number of
elements. |
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
ByteBuffer s 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.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 |
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 |
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, refCnt, release, release, retain, retain
adjustMarkers, bytesBefore, bytesBefore, bytesBefore, checkDstIndex, checkIndex, checkIndex, checkNewCapacity, checkReadableBytes, checkSrcIndex, clear, compareTo, copy, discardSomeReadBytes, ensureAccessible, equals, forEachByte, forEachByteDesc, getBoolean, getBytes, getBytes, getBytes, getChar, getDouble, getFloat, getMedium, getUnsignedByte, getUnsignedInt, getUnsignedShort, 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, readChar, readDouble, readerIndex, readerIndex, readFloat, readInt, readLong, readMedium, readShort, readSlice, readUnsignedByte, readUnsignedInt, readUnsignedMedium, readUnsignedShort, resetReaderIndex, resetWriterIndex, setBoolean, setBytes, setBytes, setBytes, setChar, setDouble, setFloat, setIndex, setZero, skipBytes, slice, toString, toString, toString, writableBytes, writeBoolean, writeByte, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeBytes, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeMedium, writerIndex, writerIndex, writeShort, writeZero
public ReadOnlyByteBuf(ByteBuf buffer)
public boolean isWritable()
ByteBuf
true
if and only if (this.capacity - this.writerIndex)
is greater
than 0
.isWritable
在类中 AbstractByteBuf
public boolean isWritable(int numBytes)
ByteBuf
true
if and only if this buffer has enough room to allow writing the specified number of
elements.isWritable
在类中 AbstractByteBuf
public int ensureWritable(int minWritableBytes, boolean force)
ByteBuf
ByteBuf.ensureWritable(int)
,
this method does not raise an exception but returns a code.ensureWritable
在类中 AbstractByteBuf
minWritableBytes
- the expected minimum number of writable bytesforce
- When ByteBuf.writerIndex()
+ minWritableBytes
> ByteBuf.maxCapacity()
:
true
- the capacity of the buffer is expanded to ByteBuf.maxCapacity()
false
- the capacity of the buffer is unchanged0
if the buffer has enough writable bytes, and its capacity is unchanged.
1
if the buffer does not have enough bytes, and its capacity is unchanged.
2
if the buffer has enough writable bytes, and its capacity has been increased.
3
if the buffer does not have enough bytes, but its capacity has been
increased to its maximum.public ByteBuf ensureWritable(int minWritableBytes)
ByteBuf
IllegalArgumentException
.ensureWritable
在类中 AbstractByteBuf
minWritableBytes
- the expected minimum number of writable bytespublic ByteBuf unwrap()
ByteBuf
public ByteBufAllocator alloc()
ByteBuf
ByteBufAllocator
which created this buffer.@Deprecated public java.nio.ByteOrder order()
ByteBuf
public boolean isDirect()
ByteBuf
true
if and only if this buffer is backed by an
NIO direct buffer.public boolean hasArray()
ByteBuf
true
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()
ByteBuf
public int arrayOffset()
ByteBuf
arrayOffset
在类中 ByteBuf
public 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
在类中 ByteBuf
public long memoryAddress()
ByteBuf
memoryAddress
在类中 ByteBuf
public ByteBuf discardReadBytes()
ByteBuf
readerIndex
.
It moves the bytes between readerIndex
and writerIndex
to the 0th index, and sets readerIndex
and writerIndex
to 0
and oldWriterIndex - oldReaderIndex
respectively.
Please refer to the class documentation for more detailed explanation.
discardReadBytes
在类中 AbstractByteBuf
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.public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.public ByteBuf setBytes(int index, java.nio.ByteBuffer src)
ByteBuf
index
until the source buffer's position
reaches its limit.
This method does not modify readerIndex
or writerIndex
of
this buffer.public 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
在类中 AbstractByteBuf
protected void _setByte(int index, int value)
_setByte
在类中 AbstractByteBuf
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
在类中 AbstractByteBuf
protected void _setShort(int index, int value)
_setShort
在类中 AbstractByteBuf
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
在类中 AbstractByteBuf
protected void _setMedium(int index, int value)
_setMedium
在类中 AbstractByteBuf
public ByteBuf setInt(int index, int value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setInt
在类中 AbstractByteBuf
protected void _setInt(int index, int value)
_setInt
在类中 AbstractByteBuf
public ByteBuf setLong(int index, long value)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.setLong
在类中 AbstractByteBuf
protected void _setLong(int index, long value)
_setLong
在类中 AbstractByteBuf
public int setBytes(int index, java.io.InputStream in, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.public int setBytes(int index, java.nio.channels.ScatteringByteChannel in, int length)
ByteBuf
index
.
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
ByteBuf
index
.
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
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of
this buffer.public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length)
ByteBuf
index
.
This method does not modify readerIndex
or writerIndex
of this buffer.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.public ByteBuf getBytes(int index, java.nio.ByteBuffer dst)
ByteBuf
index
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 duplicate()
ByteBuf
readerIndex
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
在类中 AbstractByteBuf
ByteBuf.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)
ByteBuf
readerIndex
or writerIndex
of
this buffer.public ByteBuf slice(int index, int length)
ByteBuf
readerIndex
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
在类中 AbstractByteBuf
public byte getByte(int index)
ByteBuf
index
in this buffer.
This method does not modify readerIndex
or writerIndex
of
this buffer.getByte
在类中 AbstractByteBuf
protected byte _getByte(int index)
_getByte
在类中 AbstractByteBuf
public short getShort(int index)
ByteBuf
index
in
this buffer. This method does not modify readerIndex
or
writerIndex
of this buffer.getShort
在类中 AbstractByteBuf
protected short _getShort(int index)
_getShort
在类中 AbstractByteBuf
public int getUnsignedMedium(int index)
ByteBuf
index
in this buffer. This method does not modify
readerIndex
or writerIndex
of this buffer.getUnsignedMedium
在类中 AbstractByteBuf
protected int _getUnsignedMedium(int index)
_getUnsignedMedium
在类中 AbstractByteBuf
public int getInt(int index)
ByteBuf
index
in
this buffer. This method does not modify readerIndex
or
writerIndex
of this buffer.getInt
在类中 AbstractByteBuf
protected int _getInt(int index)
_getInt
在类中 AbstractByteBuf
public long getLong(int index)
ByteBuf
index
in
this buffer. This method does not modify readerIndex
or
writerIndex
of this buffer.getLong
在类中 AbstractByteBuf
protected long _getLong(int index)
_getLong
在类中 AbstractByteBuf
public int nioBufferCount()
ByteBuf
ByteBuffer
s that consist this buffer. Note that ByteBuf.nioBuffers()
or ByteBuf.nioBuffers(int, int)
might return a less number of ByteBuffer
s.nioBufferCount
在类中 ByteBuf
-1
if this buffer has no underlying ByteBuffer
.
the number of the underlying ByteBuffer
s 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)
ByteBuf
ByteBuffer
. 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)
ByteBuf
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.
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, ByteBufProcessor processor)
ByteBuf
processor
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 ByteBufProcessor.process(byte)
returned false
.public int forEachByteDesc(int index, int length, ByteBufProcessor processor)
ByteBuf
processor
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 ByteBufProcessor.process(byte)
returned false
.public int capacity()
ByteBuf
public ByteBuf capacity(int newCapacity)
ByteBuf
newCapacity
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)
.