Interface ActiveMQBuffer
-
- All Superinterfaces:
DataInput
public interface ActiveMQBuffer extends DataInput
An ActiveMQBuffer wraps a Netty's ChannelBuffer and is used throughout ActiveMQ Artemis code base.Instances of it can be obtained from
ActiveMQBuffers
factory.Much of it derived from Netty ChannelBuffer by Trustin Lee
- See Also:
ActiveMQBuffers
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description io.netty.buffer.ByteBuf
byteBuf()
Returns the underlying Netty's ByteBufint
capacity()
Returns the number of bytes this buffer can contain.void
clear()
Sets thereaderIndex
andwriterIndex
of this buffer to0
.ActiveMQBuffer
copy()
Returns a copy of this buffer's readable bytes.ActiveMQBuffer
copy(int index, int length)
Returns a copy of this buffer's sub-region.void
discardReadBytes()
Discards the bytes between the 0th index andreaderIndex
.ActiveMQBuffer
duplicate()
Returns a buffer which shares the whole region of this buffer.byte
getByte(int index)
Gets a byte at the specified absoluteindex
in this buffer.void
getBytes(int index, byte[] dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.void
getBytes(int index, byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.void
getBytes(int index, ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination's position reaches its limit.void
getBytes(int index, ActiveMQBuffer dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination becomes non-writable.void
getBytes(int index, ActiveMQBuffer dst, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.void
getBytes(int index, ActiveMQBuffer dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
.char
getChar(int index)
Gets a char at the specified absoluteindex
in this buffer.double
getDouble(int index)
Gets a double at the specified absoluteindex
in this buffer.float
getFloat(int index)
Gets a float at the specified absoluteindex
in this buffer.int
getInt(int index)
Gets a 32-bit integer at the specified absoluteindex
in this buffer.long
getLong(int index)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer.short
getShort(int index)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer.short
getUnsignedByte(int index)
Gets an unsigned byte at the specified absoluteindex
in this buffer.long
getUnsignedInt(int index)
Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer.int
getUnsignedShort(int index)
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer.void
markReaderIndex()
Marks the currentreaderIndex
in this buffer.void
markWriterIndex()
Marks the currentwriterIndex
in this buffer.boolean
readable()
int
readableBytes()
boolean
readBoolean()
Gets a boolean at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.byte
readByte()
Gets a byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.void
readBytes(byte[] dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=dst.length
).void
readBytes(byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).void
readBytes(ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination's position reaches its limit, and increases thereaderIndex
by the number of the transferred bytes.void
readBytes(ActiveMQBuffer dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination becomes non-writable, and increases thereaderIndex
by the number of the transferred bytes.void
readBytes(ActiveMQBuffer dst, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).void
readBytes(ActiveMQBuffer dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).char
readChar()
Gets a char at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.double
readDouble()
Gets a double at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.int
readerIndex()
void
readerIndex(int readerIndex)
Sets thereaderIndex
of this buffer.float
readFloat()
Gets a float at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.int
readInt()
Gets a 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.long
readLong()
Gets a 64-bit integer at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.Boolean
readNullableBoolean()
Gets a (potentiallynull
) boolean at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.Integer
readNullableInt()
Gets a (potentiallynull
) 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.Long
readNullableLong()
Gets a (potentiallynull
) 64-bit integer at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.SimpleString
readNullableSimpleString()
Gets a SimpleString (potentiallynull
) at the currentreaderIndex
String
readNullableString()
Gets a String (potentiallynull
) at the currentreaderIndex
short
readShort()
Gets a 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.SimpleString
readSimpleString()
Gets a non-null SimpleString at the currentreaderIndex
ActiveMQBuffer
readSlice(int length)
Returns a new slice of this buffer's sub-region starting at the currentreaderIndex
and increases thereaderIndex
by the size of the new slice (=length
).String
readString()
Gets a non-null String at the currentreaderIndex
int
readUnsignedByte()
Gets an unsigned byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.long
readUnsignedInt()
Gets an unsigned 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.int
readUnsignedShort()
Gets an unsigned 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.String
readUTF()
Gets a UTF-8 String at the currentreaderIndex
void
release()
Release any underlying resources held by this buffervoid
resetReaderIndex()
Repositions the currentreaderIndex
to the markedreaderIndex
in this buffer.void
resetWriterIndex()
Repositions the currentwriterIndex
to the markedwriterIndex
in this buffer.void
setByte(int index, byte value)
Sets the specified byte at the specified absoluteindex
in this buffer.void
setBytes(int index, byte[] src)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.void
setBytes(int index, byte[] src, int srcIndex, int length)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
.void
setBytes(int index, ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer's position reaches its limit.void
setBytes(int index, ActiveMQBuffer src)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the destination becomes unreadable.void
setBytes(int index, ActiveMQBuffer src, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.void
setBytes(int index, ActiveMQBuffer src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
.void
setChar(int index, char value)
Sets the specified char at the specified absoluteindex
in this buffer.void
setDouble(int index, double value)
Sets the specified double at the specified absoluteindex
in this buffer.void
setFloat(int index, float value)
Sets the specified float at the specified absoluteindex
in this buffer.void
setIndex(int readerIndex, int writerIndex)
Sets thereaderIndex
andwriterIndex
of this buffer in one shot.void
setInt(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer.void
setLong(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer.void
setShort(int index, short value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer.int
skipBytes(int length)
Increases the currentreaderIndex
by the specifiedlength
in this buffer.ActiveMQBuffer
slice()
Returns a slice of this buffer's readable bytes.ActiveMQBuffer
slice(int index, int length)
Returns a slice of this buffer's sub-region.ByteBuffer
toByteBuffer()
Converts this buffer's readable bytes into a NIO buffer.ByteBuffer
toByteBuffer(int index, int length)
Converts this buffer's sub-region into a NIO buffer.boolean
writable()
int
writableBytes()
void
writeBoolean(boolean val)
Sets the specified boolean at the currentwriterIndex
void
writeByte(byte value)
Sets the specified byte at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.void
writeBytes(byte[] src)
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=src.length
).void
writeBytes(byte[] src, int srcIndex, int length)
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).void
writeBytes(io.netty.buffer.ByteBuf src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer's position reaches its limit, and increases thewriterIndex
by the number of the transferred bytes.void
writeBytes(ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer's position reaches its limit, and increases thewriterIndex
by the number of the transferred bytes.void
writeBytes(ActiveMQBuffer src, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).void
writeBytes(ActiveMQBuffer src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).void
writeChar(char chr)
Sets the specified char at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.void
writeDouble(double value)
Sets the specified double at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.void
writeFloat(float value)
Sets the specified float at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.void
writeInt(int value)
Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.void
writeLong(long value)
Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.void
writeNullableBoolean(Boolean val)
Sets the specified (potentiallynull
) Boolean at the currentwriterIndex
void
writeNullableInt(Integer value)
Sets the specified (potentiallynull
) 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.void
writeNullableLong(Long value)
Sets the specified (potentiallynull
) 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.void
writeNullableSimpleString(SimpleString val)
Sets the specified SimpleString (potentiallynull
) at the currentwriterIndex
void
writeNullableString(String val)
Sets the specified String (potentiallynull
) at the currentwriterIndex
int
writerIndex()
void
writerIndex(int writerIndex)
Sets thewriterIndex
of this buffer.void
writeShort(short value)
Sets the specified 16-bit short integer at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.void
writeSimpleString(SimpleString val)
Sets the specified non-null SimpleString at the currentwriterIndex
void
writeString(String val)
Sets the specified non-null String at the currentwriterIndex
void
writeUTF(String utf)
Sets the specified UTF-8 String at the currentwriterIndex
-
-
-
Method Detail
-
byteBuf
io.netty.buffer.ByteBuf byteBuf()
Returns the underlying Netty's ByteBuf- Returns:
- the underlying Netty's ByteBuf
-
capacity
int capacity()
Returns the number of bytes this buffer can contain.- Returns:
- the number of bytes this buffer can contain.
-
readerIndex
int readerIndex()
- Returns:
- the
readerIndex
of this buffer.
-
readerIndex
void readerIndex(int readerIndex)
Sets thereaderIndex
of this buffer.- Parameters:
readerIndex
- The reader's index- Throws:
IndexOutOfBoundsException
- if the specifiedreaderIndex
is less than0
or greater thanthis.writerIndex
-
writerIndex
int writerIndex()
- Returns:
- the
writerIndex
of this buffer.
-
writerIndex
void writerIndex(int writerIndex)
Sets thewriterIndex
of this buffer.- Parameters:
writerIndex
- The writer's index- Throws:
IndexOutOfBoundsException
- if the specifiedwriterIndex
is less thanthis.readerIndex
or greater thanthis.capacity
-
setIndex
void setIndex(int readerIndex, int writerIndex)
Sets thereaderIndex
andwriterIndex
of this buffer in one shot. This method is useful when you have to worry about the invocation order ofreaderIndex(int)
andwriterIndex(int)
methods. For example, the following code will fail:// Create a buffer whose readerIndex, writerIndex and capacity are // 0, 0 and 8 respectively. ChannelBuffer buf = ChannelBuffers.buffer(8); // IndexOutOfBoundsException is thrown because the specified // readerIndex (2) cannot be greater than the current writerIndex (0). buf.readerIndex(2); buf.writerIndex(4);
The following code will also fail:// Create a buffer whose readerIndex, writerIndex and capacity are // 0, 8 and 8 respectively. ChannelBuffer buf = ChannelBuffers.wrappedBuffer(new byte[8]); // readerIndex becomes 8. buf.readLong(); // IndexOutOfBoundsException is thrown because the specified // writerIndex (4) cannot be less than the current readerIndex (8). buf.writerIndex(4); buf.readerIndex(2);
By contrast,setIndex(int, int)
guarantees that it never throws anIndexOutOfBoundsException
as long as the specified indexes meet basic constraints, regardless what the current index values of the buffer are:// No matter what the current state of the buffer is, the following // call always succeeds as long as the capacity of the buffer is not // less than 4. buf.setIndex(2, 4);
- Parameters:
readerIndex
- The reader's indexwriterIndex
- The writer's index- Throws:
IndexOutOfBoundsException
- if the specifiedreaderIndex
is less than 0, if the specifiedwriterIndex
is less than the specifiedreaderIndex
or if the specifiedwriterIndex
is greater thanthis.capacity
-
readableBytes
int readableBytes()
- Returns:
- the number of readable bytes which is equal to
(this.writerIndex - this.readerIndex)
.
-
writableBytes
int writableBytes()
- Returns:
- the number of writable bytes which is equal to
(this.capacity - this.writerIndex)
.
-
readable
boolean readable()
- Returns:
true
if and only if(this.writerIndex - this.readerIndex)
is greater than0
.
-
writable
boolean writable()
- Returns:
true
if and only if(this.capacity - this.writerIndex)
is greater than0
.
-
clear
void clear()
Sets thereaderIndex
andwriterIndex
of this buffer to0
. This method is identical tosetIndex(0, 0)
.Please note that the behavior of this method is different from that of NIO buffer, which sets the
limit
to thecapacity
of the buffer.
-
markReaderIndex
void markReaderIndex()
Marks the currentreaderIndex
in this buffer. You can reposition the currentreaderIndex
to the markedreaderIndex
by callingresetReaderIndex()
. The initial value of the markedreaderIndex
is0
.
-
resetReaderIndex
void resetReaderIndex()
Repositions the currentreaderIndex
to the markedreaderIndex
in this buffer.- Throws:
IndexOutOfBoundsException
- if the currentwriterIndex
is less than the markedreaderIndex
-
markWriterIndex
void markWriterIndex()
Marks the currentwriterIndex
in this buffer. You can reposition the currentwriterIndex
to the markedwriterIndex
by callingresetWriterIndex()
. The initial value of the markedwriterIndex
is0
.
-
resetWriterIndex
void resetWriterIndex()
Repositions the currentwriterIndex
to the markedwriterIndex
in this buffer.- Throws:
IndexOutOfBoundsException
- if the currentreaderIndex
is greater than the markedwriterIndex
-
discardReadBytes
void discardReadBytes()
Discards the bytes between the 0th index andreaderIndex
. It moves the bytes betweenreaderIndex
andwriterIndex
to the 0th index, and setsreaderIndex
andwriterIndex
to0
andoldWriterIndex - oldReaderIndex
respectively.Please refer to the class documentation for more detailed explanation.
-
getByte
byte getByte(int index)
Gets a byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffer- Returns:
- The byte at the specified index
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 1
is greater thanthis.capacity
-
getUnsignedByte
short getUnsignedByte(int index)
Gets an unsigned byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffer- Returns:
- an unsigned byte at the specified absolute
index
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 1
is greater thanthis.capacity
-
getShort
short getShort(int index)
Gets a 16-bit short integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffer- Returns:
- a 16-bit short integer at the specified absolute
index
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
getUnsignedShort
int getUnsignedShort(int index)
Gets an unsigned 16-bit short integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffer- Returns:
- an unsigned 16-bit short integer
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
getInt
int getInt(int index)
Gets a 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffer- Returns:
- a 32-bit integer at the specified absolute
index
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getUnsignedInt
long getUnsignedInt(int index)
Gets an unsigned 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- The index into this buffer- Returns:
- an unsigned 32-bit integer at the specified absolute
index
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getLong
long getLong(int index)
Gets a 64-bit long integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffer- Returns:
- a 64-bit long integer at the specified absolute
index
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
getBytes
void getBytes(int index, ActiveMQBuffer dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination becomes non-writable. This method is basically same withgetBytes(int, ActiveMQBuffer, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whilegetBytes(int, ActiveMQBuffer, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Parameters:
index
- Index into the bufferdst
- The destination buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + dst.writableBytes
is greater thanthis.capacity
-
getBytes
void getBytes(int index, ActiveMQBuffer dst, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method is basically same withgetBytes(int, ActiveMQBuffer, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whilegetBytes(int, ActiveMQBuffer, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Parameters:
length
- the number of bytes to transferindex
- Index into the bufferdst
- The destination buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, ifindex + length
is greater thanthis.capacity
, or iflength
is greater thandst.writableBytes
-
getBytes
void getBytes(int index, ActiveMQBuffer dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination.- Parameters:
dst
- The destination bufferIndex the first index of the destinationlength
- The number of bytes to transferindex
- Index into the bufferdstIndex
- The index into the destination bufferThe destination buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, if the specifieddstIndex
is less than0
, ifindex + length
is greater thanthis.capacity
, or ifdstIndex + length
is greater thandst.capacity
-
getBytes
void getBytes(int index, byte[] dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer- Parameters:
index
- Index into the bufferdst
- The destination buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + dst.length
is greater thanthis.capacity
-
getBytes
void getBytes(int index, byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
dstIndex
- The first index of the destinationlength
- The number of bytes to transferindex
- Index into the bufferdst
- The destination buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, if the specifieddstIndex
is less than0
, ifindex + length
is greater thanthis.capacity
, or ifdstIndex + length
is greater thandst.length
-
getBytes
void getBytes(int index, ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at the specified absoluteindex
until the destination's position reaches its limit. This method does not modifyreaderIndex
orwriterIndex
of this buffer while the destination'sposition
will be increased.- Parameters:
index
- Index into the bufferdst
- The destination buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + dst.remaining()
is greater thanthis.capacity
-
getChar
char getChar(int index)
Gets a char at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffer- Returns:
- a char at the specified absolute
index
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
getFloat
float getFloat(int index)
Gets a float at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffer- Returns:
- a float at the specified absolute
index
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
getDouble
double getDouble(int index)
Gets a double at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffer- Returns:
- a double at the specified absolute
index
- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
setByte
void setByte(int index, byte value)
Sets the specified byte at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffervalue
- The specified byte- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 1
is greater thanthis.capacity
-
setShort
void setShort(int index, short value)
Sets the specified 16-bit short integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffervalue
- The specified 16-bit short integer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
setInt
void setInt(int index, int value)
Sets the specified 32-bit integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffervalue
- The specified 32-bit integer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
setLong
void setLong(int index, long value)
Sets the specified 64-bit long integer at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffervalue
- The specified 64-bit long integer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
setBytes
void setBytes(int index, ActiveMQBuffer src)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the destination becomes unreadable. This method is basically same withsetBytes(int, ActiveMQBuffer, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whilegetBytes(int, ActiveMQBuffer, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Parameters:
index
- Index into the buffersrc
- The source buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + src.readableBytes
is greater thanthis.capacity
-
setBytes
void setBytes(int index, ActiveMQBuffer src, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method is basically same withsetBytes(int, ActiveMQBuffer, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes whilegetBytes(int, ActiveMQBuffer, int, int)
does not. This method does not modifyreaderIndex
orwriterIndex
of the source buffer (i.e.this
).- Parameters:
length
- the number of bytes to transferindex
- Index into the buffersrc
- The source buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, ifindex + length
is greater thanthis.capacity
, or iflength
is greater thansrc.readableBytes
-
setBytes
void setBytes(int index, ActiveMQBuffer src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of both the source (i.e.this
) and the destination.- Parameters:
src
- The source bufferIndex the first index of the sourcelength
- The number of bytes to transferindex
- Index into the buffersrcIndex
- The source buffer index- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, if the specifiedsrcIndex
is less than0
, ifindex + length
is greater thanthis.capacity
, or ifsrcIndex + length
is greater thansrc.capacity
-
setBytes
void setBytes(int index, byte[] src)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffersrc
- The source buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + src.length
is greater thanthis.capacity
-
setBytes
void setBytes(int index, byte[] src, int srcIndex, int length)
Transfers the specified source array's data to this buffer starting at the specified absoluteindex
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffersrc
- The source buffersrcIndex
- The source buffer indexlength
- The number of bytes to transfer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
, if the specifiedsrcIndex
is less than0
, ifindex + length
is greater thanthis.capacity
, or ifsrcIndex + length
is greater thansrc.length
-
setBytes
void setBytes(int index, ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex
until the source buffer's position reaches its limit. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffersrc
- The source buffer- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
or ifindex + src.remaining()
is greater thanthis.capacity
-
setChar
void setChar(int index, char value)
Sets the specified char at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffervalue
- The specified char- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 2
is greater thanthis.capacity
-
setFloat
void setFloat(int index, float value)
Sets the specified float at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffervalue
- The specified float- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 4
is greater thanthis.capacity
-
setDouble
void setDouble(int index, double value)
Sets the specified double at the specified absoluteindex
in this buffer. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the buffervalue
- The specified double- Throws:
IndexOutOfBoundsException
- if the specifiedindex
is less than0
orindex + 8
is greater thanthis.capacity
-
readByte
byte readByte()
Gets a byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Specified by:
readByte
in interfaceDataInput
- Returns:
- a byte at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than1
-
readUnsignedByte
int readUnsignedByte()
Gets an unsigned byte at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Specified by:
readUnsignedByte
in interfaceDataInput
- Returns:
- an unsigned byte at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than1
-
readShort
short readShort()
Gets a 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.- Specified by:
readShort
in interfaceDataInput
- Returns:
- a 16-bit short integer at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than2
-
readUnsignedShort
int readUnsignedShort()
Gets an unsigned 16-bit short integer at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.- Specified by:
readUnsignedShort
in interfaceDataInput
- Returns:
- an unsigned 16-bit short integer at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than2
-
readInt
int readInt()
Gets a 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.- Specified by:
readInt
in interfaceDataInput
- Returns:
- a 32-bit integer at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readNullableInt
Integer readNullableInt()
Gets a (potentiallynull
) 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.- Returns:
- a (potentially
null
) 32-bit integer at the currentreaderIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readUnsignedInt
long readUnsignedInt()
Gets an unsigned 32-bit integer at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.- Returns:
- an unsigned 32-bit integer at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readLong
long readLong()
Gets a 64-bit integer at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.- Specified by:
readLong
in interfaceDataInput
- Returns:
- a 64-bit integer at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than8
-
readNullableLong
Long readNullableLong()
Gets a (potentiallynull
) 64-bit integer at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.- Returns:
- a (potentially
null
) 64-bit integer at the currentreaderIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than8
-
readChar
char readChar()
Gets a char at the currentreaderIndex
and increases thereaderIndex
by2
in this buffer.- Specified by:
readChar
in interfaceDataInput
- Returns:
- a char at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than2
-
readFloat
float readFloat()
Gets a float at the currentreaderIndex
and increases thereaderIndex
by4
in this buffer.- Specified by:
readFloat
in interfaceDataInput
- Returns:
- a float at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than4
-
readDouble
double readDouble()
Gets a double at the currentreaderIndex
and increases thereaderIndex
by8
in this buffer.- Specified by:
readDouble
in interfaceDataInput
- Returns:
- a double at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than8
-
readBoolean
boolean readBoolean()
Gets a boolean at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Specified by:
readBoolean
in interfaceDataInput
- Returns:
- a boolean at the current
readerIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than1
-
readNullableBoolean
Boolean readNullableBoolean()
Gets a (potentiallynull
) boolean at the currentreaderIndex
and increases thereaderIndex
by1
in this buffer.- Returns:
- a (potentially
null
) boolean at the currentreaderIndex
- Throws:
IndexOutOfBoundsException
- ifthis.readableBytes
is less than1
-
readNullableSimpleString
SimpleString readNullableSimpleString()
Gets a SimpleString (potentiallynull
) at the currentreaderIndex
- Returns:
- a SimpleString (potentially
null
) at the currentreaderIndex
-
readNullableString
String readNullableString()
Gets a String (potentiallynull
) at the currentreaderIndex
- Returns:
- a String (potentially
null
) at the currentreaderIndex
-
readSimpleString
SimpleString readSimpleString()
Gets a non-null SimpleString at the currentreaderIndex
- Returns:
- a non-null SimpleString at the current
readerIndex
-
readString
String readString()
Gets a non-null String at the currentreaderIndex
- Returns:
- a non-null String at the current
readerIndex
-
readUTF
String readUTF()
Gets a UTF-8 String at the currentreaderIndex
-
readSlice
ActiveMQBuffer readSlice(int length)
Returns a new slice of this buffer's sub-region starting at the currentreaderIndex
and increases thereaderIndex
by the size of the new slice (=length
).- Parameters:
length
- the size of the new slice- Returns:
- the newly created slice
- Throws:
IndexOutOfBoundsException
- iflength
is greater thanthis.readableBytes
-
readBytes
void readBytes(ActiveMQBuffer dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination becomes non-writable, and increases thereaderIndex
by the number of the transferred bytes. This method is basically same withreadBytes(ActiveMQBuffer, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes whilereadBytes(ActiveMQBuffer, int, int)
does not.- Parameters:
dst
- The destination buffer- Throws:
IndexOutOfBoundsException
- ifdst.writableBytes
is greater thanthis.readableBytes
-
readBytes
void readBytes(ActiveMQBuffer dst, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
). This method is basically same withreadBytes(ActiveMQBuffer, int, int)
, except that this method increases thewriterIndex
of the destination by the number of the transferred bytes (=length
) whilereadBytes(ActiveMQBuffer, int, int)
does not.- Parameters:
dst
- The destination bufferlength
- The number of bytes to transfer- Throws:
IndexOutOfBoundsException
- iflength
is greater thanthis.readableBytes
or iflength
is greater thandst.writableBytes
-
readBytes
void readBytes(ActiveMQBuffer dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).- Parameters:
dstIndex
- The destination buffer indexlength
- the number of bytes to transferdst
- The destination buffer- Throws:
IndexOutOfBoundsException
- if the specifieddstIndex
is less than0
, iflength
is greater thanthis.readableBytes
, or ifdstIndex + length
is greater thandst.capacity
-
readBytes
void readBytes(byte[] dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=dst.length
).- Parameters:
dst
- The destination buffer- Throws:
IndexOutOfBoundsException
- ifdst.length
is greater thanthis.readableBytes
-
readBytes
void readBytes(byte[] dst, int dstIndex, int length)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
and increases thereaderIndex
by the number of the transferred bytes (=length
).- Parameters:
dstIndex
- The destination bufferIndexlength
- the number of bytes to transferdst
- The destination buffer- Throws:
IndexOutOfBoundsException
- if the specifieddstIndex
is less than0
, iflength
is greater thanthis.readableBytes
, or ifdstIndex + length
is greater thandst.length
-
readBytes
void readBytes(ByteBuffer dst)
Transfers this buffer's data to the specified destination starting at the currentreaderIndex
until the destination's position reaches its limit, and increases thereaderIndex
by the number of the transferred bytes.- Parameters:
dst
- The destination buffer- Throws:
IndexOutOfBoundsException
- ifdst.remaining()
is greater thanthis.readableBytes
-
skipBytes
int skipBytes(int length)
Increases the currentreaderIndex
by the specifiedlength
in this buffer.- Specified by:
skipBytes
in interfaceDataInput
- Parameters:
length
- The number of bytes to skip- Throws:
IndexOutOfBoundsException
- iflength
is greater thanthis.readableBytes
-
writeByte
void writeByte(byte value)
Sets the specified byte at the currentwriterIndex
and increases thewriterIndex
by1
in this buffer.- Parameters:
value
- The specified byte- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than1
-
writeShort
void writeShort(short value)
Sets the specified 16-bit short integer at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.- Parameters:
value
- The specified 16-bit short integer- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than2
-
writeInt
void writeInt(int value)
Sets the specified 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.- Parameters:
value
- The specified 32-bit integer- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than4
-
writeNullableInt
void writeNullableInt(Integer value)
Sets the specified (potentiallynull
) 32-bit integer at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.- Parameters:
value
- The specified (potentiallynull
) 32-bit integer- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than4
-
writeLong
void writeLong(long value)
Sets the specified 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.- Parameters:
value
- The specified 64-bit long integer- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than8
-
writeNullableLong
void writeNullableLong(Long value)
Sets the specified (potentiallynull
) 64-bit long integer at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.- Parameters:
value
- The specified (potentiallynull
) 64-bit long integer- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than8
-
writeChar
void writeChar(char chr)
Sets the specified char at the currentwriterIndex
and increases thewriterIndex
by2
in this buffer.- Parameters:
chr
- The specified char- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than2
-
writeFloat
void writeFloat(float value)
Sets the specified float at the currentwriterIndex
and increases thewriterIndex
by4
in this buffer.- Parameters:
value
- The specified float- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than4
-
writeDouble
void writeDouble(double value)
Sets the specified double at the currentwriterIndex
and increases thewriterIndex
by8
in this buffer.- Parameters:
value
- The specified double- Throws:
IndexOutOfBoundsException
- ifthis.writableBytes
is less than8
-
writeBoolean
void writeBoolean(boolean val)
Sets the specified boolean at the currentwriterIndex
- Parameters:
val
- The specified boolean
-
writeNullableBoolean
void writeNullableBoolean(Boolean val)
Sets the specified (potentiallynull
) Boolean at the currentwriterIndex
- Parameters:
val
- The specified boolean
-
writeNullableSimpleString
void writeNullableSimpleString(SimpleString val)
Sets the specified SimpleString (potentiallynull
) at the currentwriterIndex
- Parameters:
val
- The specified SimpleString
-
writeNullableString
void writeNullableString(String val)
Sets the specified String (potentiallynull
) at the currentwriterIndex
- Parameters:
val
- The specified String
-
writeSimpleString
void writeSimpleString(SimpleString val)
Sets the specified non-null SimpleString at the currentwriterIndex
- Parameters:
val
- The specified non-null SimpleString
-
writeString
void writeString(String val)
Sets the specified non-null String at the currentwriterIndex
- Parameters:
val
- The specified non-null String
-
writeUTF
void writeUTF(String utf)
Sets the specified UTF-8 String at the currentwriterIndex
- Parameters:
utf
- The specified UTF-8 String
-
writeBytes
void writeBytes(ActiveMQBuffer src, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
). This method is basically same withwriteBytes(ActiveMQBuffer, int, int)
, except that this method increases thereaderIndex
of the source buffer by the number of the transferred bytes (=length
) whilewriteBytes(ActiveMQBuffer, int, int)
does not.- Parameters:
length
- the number of bytes to transfersrc
- The source buffer- Throws:
IndexOutOfBoundsException
- iflength
is greater thanthis.writableBytes
or iflength
is greater thensrc.readableBytes
-
writeBytes
void writeBytes(ActiveMQBuffer src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).- Parameters:
srcIndex
- the first index of the sourcelength
- the number of bytes to transfersrc
- The source buffer- Throws:
IndexOutOfBoundsException
- if the specifiedsrcIndex
is less than0
, ifsrcIndex + length
is greater thansrc.capacity
, or iflength
is greater thanthis.writableBytes
-
writeBytes
void writeBytes(byte[] src)
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=src.length
).- Parameters:
src
- The source buffer- Throws:
IndexOutOfBoundsException
- ifsrc.length
is greater thanthis.writableBytes
-
writeBytes
void writeBytes(byte[] src, int srcIndex, int length)
Transfers the specified source array's data to this buffer starting at the currentwriterIndex
and increases thewriterIndex
by the number of the transferred bytes (=length
).- Parameters:
srcIndex
- the first index of the sourcelength
- the number of bytes to transfersrc
- The source buffer- Throws:
IndexOutOfBoundsException
- if the specifiedsrcIndex
is less than0
, ifsrcIndex + length
is greater thansrc.length
, or iflength
is greater thanthis.writableBytes
-
writeBytes
void writeBytes(ByteBuffer src)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer's position reaches its limit, and increases thewriterIndex
by the number of the transferred bytes.- Parameters:
src
- The source buffer- Throws:
IndexOutOfBoundsException
- ifsrc.remaining()
is greater thanthis.writableBytes
-
writeBytes
void writeBytes(io.netty.buffer.ByteBuf src, int srcIndex, int length)
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndex
until the source buffer's position reaches its limit, and increases thewriterIndex
by the number of the transferred bytes.- Parameters:
src
- The source buffer- Throws:
IndexOutOfBoundsException
- ifsrc.remaining()
is greater thanthis.writableBytes
-
copy
ActiveMQBuffer copy()
Returns a copy of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer does not affect each other at all. This method is identical tobuf.copy(buf.readerIndex(), buf.readableBytes())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- a copy of this buffer's readable bytes.
-
copy
ActiveMQBuffer copy(int index, int length)
Returns 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 modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the bufferlength
- The number of bytes to copy- Returns:
- a copy of this buffer's readable bytes.
-
slice
ActiveMQBuffer slice()
Returns a slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical tobuf.slice(buf.readerIndex(), buf.readableBytes())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- a slice of this buffer's readable bytes
-
slice
ActiveMQBuffer slice(int index, int length)
Returns a slice of this buffer's sub-region. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the bufferlength
- The number of bytes- Returns:
- a slice of this buffer's sub-region.
-
duplicate
ActiveMQBuffer duplicate()
Returns a buffer which shares the whole region of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical tobuf.slice(0, buf.capacity())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- a buffer which shares the whole region of this buffer.
-
toByteBuffer
ByteBuffer toByteBuffer()
Converts this buffer's readable bytes into a NIO buffer. The returned buffer might or might not share the content with this buffer, while they have separate indexes and marks. This method is identical tobuf.toByteBuffer(buf.readerIndex(), buf.readableBytes())
. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Returns:
- A converted NIO ByteBuffer
-
toByteBuffer
ByteBuffer toByteBuffer(int index, int length)
Converts this buffer's sub-region into a NIO buffer. The returned buffer might or might not share the content with this buffer, while they have separate indexes and marks. This method does not modifyreaderIndex
orwriterIndex
of this buffer.- Parameters:
index
- Index into the bufferlength
- The number of bytes- Returns:
- A converted NIO Buffer
-
release
void release()
Release any underlying resources held by this buffer
-
-