Interface ActiveMQBuffer
- All Superinterfaces:
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:
-
Method Summary
Modifier and TypeMethodDescriptionio.netty.buffer.ByteBufbyteBuf()Returns the underlying Netty's ByteBuf.intcapacity()Returns the number of bytes this buffer can contain.voidclear()Sets thereaderIndexandwriterIndexof this buffer to0.copy()Returns a copy of this buffer's readable bytes.copy(int index, int length) Returns a copy of this buffer's sub-region.voidDiscards the bytes between the 0th index andreaderIndex.Returns a buffer which shares the whole region of this buffer.bytegetByte(int index) Gets a byte at the specified absoluteindexin this buffer.voidgetBytes(int index, byte[] dst) Transfers this buffer's data to the specified destination starting at the specified absoluteindex.voidgetBytes(int index, byte[] dst, int dstIndex, int length) Transfers this buffer's data to the specified destination starting at the specified absoluteindex.voidgetBytes(int index, ByteBuffer dst) Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination's position reaches its limit.voidgetBytes(int index, ActiveMQBuffer dst) Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination becomes non-writable.voidgetBytes(int index, ActiveMQBuffer dst, int length) Transfers this buffer's data to the specified destination starting at the specified absoluteindex.voidgetBytes(int index, ActiveMQBuffer dst, int dstIndex, int length) Transfers this buffer's data to the specified destination starting at the specified absoluteindex.chargetChar(int index) Gets a char at the specified absoluteindexin this buffer.doublegetDouble(int index) Gets a double at the specified absoluteindexin this buffer.floatgetFloat(int index) Gets a float at the specified absoluteindexin this buffer.intgetInt(int index) Gets a 32-bit integer at the specified absoluteindexin this buffer.longgetLong(int index) Gets a 64-bit long integer at the specified absoluteindexin this buffer.shortgetShort(int index) Gets a 16-bit short integer at the specified absoluteindexin this buffer.shortgetUnsignedByte(int index) Gets an unsigned byte at the specified absoluteindexin this buffer.longgetUnsignedInt(int index) Gets an unsigned 32-bit integer at the specified absoluteindexin this buffer.intgetUnsignedShort(int index) Gets an unsigned 16-bit short integer at the specified absoluteindexin this buffer.voidMarks the currentreaderIndexin this buffer.voidMarks the currentwriterIndexin this buffer.booleanreadable()Returnstrueif and only if(this.writerIndex - this.readerIndex)is greater than0.intReturns the number of readable bytes which is equal to(this.writerIndex - this.readerIndex).booleanGets a boolean at the currentreaderIndexand increases thereaderIndexby1in this buffer.bytereadByte()Gets a byte at the currentreaderIndexand increases thereaderIndexby1in this buffer.voidreadBytes(byte[] dst) Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=dst.length).voidreadBytes(byte[] dst, int dstIndex, int length) Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).voidreadBytes(ByteBuffer dst) Transfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination's position reaches its limit, and increases thereaderIndexby the number of the transferred bytes.voidreadBytes(ActiveMQBuffer dst) Transfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination becomes non-writable, and increases thereaderIndexby the number of the transferred bytes.voidreadBytes(ActiveMQBuffer dst, int length) Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).voidreadBytes(ActiveMQBuffer dst, int dstIndex, int length) Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length).charreadChar()Gets a char at the currentreaderIndexand increases thereaderIndexby2in this buffer.doubleGets a double at the currentreaderIndexand increases thereaderIndexby8in this buffer.intReturns thereaderIndexof this buffer..voidreaderIndex(int readerIndex) Sets thereaderIndexof this buffer.floatGets a float at the currentreaderIndexand increases thereaderIndexby4in this buffer.intreadInt()Gets a 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.longreadLong()Gets a 64-bit integer at the currentreaderIndexand increases thereaderIndexby8in this buffer.Gets a (potentiallynull) boolean at the currentreaderIndexand increases thereaderIndexby1in this buffer.Gets a (potentiallynull) 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.Gets a (potentiallynull) 64-bit integer at the currentreaderIndexand increases thereaderIndexby8in this buffer.Gets a SimpleString (potentiallynull) at the currentreaderIndexGets a String (potentiallynull) at the currentreaderIndexshortGets a 16-bit short integer at the currentreaderIndexand increases thereaderIndexby2in this buffer.Gets a non-null SimpleString at the currentreaderIndexreadSlice(int length) Returns a new slice of this buffer's sub-region starting at the currentreaderIndexand increases thereaderIndexby the size of the new slice (=length).Gets a non-null String at the currentreaderIndexintGets an unsigned byte at the currentreaderIndexand increases thereaderIndexby1in this buffer.longGets an unsigned 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.intGets an unsigned 16-bit short integer at the currentreaderIndexand increases thereaderIndexby2in this buffer.readUTF()Gets a UTF-8 String at the currentreaderIndexvoidrelease()Release any underlying resources held by this buffervoidRepositions the currentreaderIndexto the markedreaderIndexin this buffer.voidRepositions the currentwriterIndexto the markedwriterIndexin this buffer.voidsetByte(int index, byte value) Sets the specified byte at the specified absoluteindexin this buffer.voidsetBytes(int index, byte[] src) Transfers the specified source array's data to this buffer starting at the specified absoluteindex.voidsetBytes(int index, byte[] src, int srcIndex, int length) Transfers the specified source array's data to this buffer starting at the specified absoluteindex.voidsetBytes(int index, 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.voidsetBytes(int index, ActiveMQBuffer src) Transfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the destination becomes unreadable.voidsetBytes(int index, ActiveMQBuffer src, int length) Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex.voidsetBytes(int index, ActiveMQBuffer src, int srcIndex, int length) Transfers the specified source buffer's data to this buffer starting at the specified absoluteindex.voidsetChar(int index, char value) Sets the specified char at the specified absoluteindexin this buffer.voidsetDouble(int index, double value) Sets the specified double at the specified absoluteindexin this buffer.voidsetFloat(int index, float value) Sets the specified float at the specified absoluteindexin this buffer.voidsetIndex(int readerIndex, int writerIndex) Sets thereaderIndexandwriterIndexof this buffer in one shot.voidsetInt(int index, int value) Sets the specified 32-bit integer at the specified absoluteindexin this buffer.voidsetLong(int index, long value) Sets the specified 64-bit long integer at the specified absoluteindexin this buffer.voidsetShort(int index, short value) Sets the specified 16-bit short integer at the specified absoluteindexin this buffer.intskipBytes(int length) Increases the currentreaderIndexby the specifiedlengthin this buffer.slice()Returns a slice of this buffer's readable bytes.slice(int index, int length) Returns a slice of this buffer's sub-region.Converts this buffer's readable bytes into a NIO buffer.toByteBuffer(int index, int length) Converts this buffer's sub-region into a NIO buffer.booleanwritable()Returnstrueif and only if(this.capacity - this.writerIndex)is greater than0.intReturns the number of writable bytes which is equal to(this.capacity - this.writerIndex).voidwriteBoolean(boolean val) Sets the specified boolean at the currentwriterIndexvoidwriteByte(byte value) Sets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer.voidwriteBytes(byte[] src) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=src.length).voidwriteBytes(byte[] src, int srcIndex, int length) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).voidwriteBytes(io.netty.buffer.ByteBuf src, int srcIndex, int length) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby the number of the transferred bytes.voidwriteBytes(ByteBuffer src) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby the number of the transferred bytes.voidwriteBytes(ActiveMQBuffer src, int length) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).voidwriteBytes(ActiveMQBuffer src, int srcIndex, int length) Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length).voidwriteChar(char chr) Sets the specified char at the currentwriterIndexand increases thewriterIndexby2in this buffer.voidwriteDouble(double value) Sets the specified double at the currentwriterIndexand increases thewriterIndexby8in this buffer.voidwriteFloat(float value) Sets the specified float at the currentwriterIndexand increases thewriterIndexby4in this buffer.voidwriteInt(int value) Sets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.voidwriteLong(long value) Sets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.voidSets the specified (potentiallynull) Boolean at the currentwriterIndexvoidwriteNullableInt(Integer value) Sets the specified (potentiallynull) 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.voidwriteNullableLong(Long value) Sets the specified (potentiallynull) 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.voidSets the specified SimpleString (potentiallynull) at the currentwriterIndexvoidSets the specified String (potentiallynull) at the currentwriterIndexintReturns thewriterIndexof this buffer..voidwriterIndex(int writerIndex) Sets thewriterIndexof this buffer.voidwriteShort(short value) Sets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer.voidSets the specified non-null SimpleString at the currentwriterIndexvoidwriteString(String val) Sets the specified non-null String at the currentwriterIndexvoidSets the specified UTF-8 String at the currentwriterIndex
-
Method Details
-
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 thereaderIndexof this buffer..- Returns:
- the
readerIndexof this buffer.
-
readerIndex
void readerIndex(int readerIndex) Sets thereaderIndexof this buffer.- Parameters:
readerIndex- The reader's index- Throws:
IndexOutOfBoundsException- if the specifiedreaderIndexis less than0or greater thanthis.writerIndex
-
writerIndex
int writerIndex()Returns thewriterIndexof this buffer..- Returns:
- the
writerIndexof this buffer.
-
writerIndex
void writerIndex(int writerIndex) Sets thewriterIndexof this buffer.- Parameters:
writerIndex- The writer's index- Throws:
IndexOutOfBoundsException- if the specifiedwriterIndexis less thanthis.readerIndexor greater thanthis.capacity
-
setIndex
void setIndex(int readerIndex, int writerIndex) Sets thereaderIndexandwriterIndexof 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 anIndexOutOfBoundsExceptionas 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 specifiedreaderIndexis less than 0, if the specifiedwriterIndexis less than the specifiedreaderIndexor if the specifiedwriterIndexis greater thanthis.capacity
-
readableBytes
int readableBytes()Returns the number of readable bytes which is equal to(this.writerIndex - this.readerIndex).- 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).- Returns:
- the number of writable bytes which is equal to
(this.capacity - this.writerIndex)
-
readable
boolean readable()Returnstrueif and only if(this.writerIndex - this.readerIndex)is greater than0.- Returns:
trueif and only if(this.writerIndex - this.readerIndex)is greater than0
-
writable
boolean writable()Returnstrueif and only if(this.capacity - this.writerIndex)is greater than0.- Returns:
trueif and only if(this.capacity - this.writerIndex)is greater than0
-
clear
void clear()Sets thereaderIndexandwriterIndexof 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
limitto thecapacityof the buffer. -
markReaderIndex
void markReaderIndex()Marks the currentreaderIndexin this buffer. You can reposition the currentreaderIndexto the markedreaderIndexby callingresetReaderIndex(). The initial value of the markedreaderIndexis0. -
resetReaderIndex
void resetReaderIndex()Repositions the currentreaderIndexto the markedreaderIndexin this buffer.- Throws:
IndexOutOfBoundsException- if the currentwriterIndexis less than the markedreaderIndex
-
markWriterIndex
void markWriterIndex()Marks the currentwriterIndexin this buffer. You can reposition the currentwriterIndexto the markedwriterIndexby callingresetWriterIndex(). The initial value of the markedwriterIndexis0. -
resetWriterIndex
void resetWriterIndex()Repositions the currentwriterIndexto the markedwriterIndexin this buffer.- Throws:
IndexOutOfBoundsException- if the currentreaderIndexis greater than the markedwriterIndex
-
discardReadBytes
void discardReadBytes()Discards the bytes between the 0th index andreaderIndex. It moves the bytes betweenreaderIndexandwriterIndexto the 0th index, and setsreaderIndexandwriterIndexto0andoldWriterIndex - oldReaderIndexrespectively.Please refer to the class documentation for more detailed explanation.
-
getByte
byte getByte(int index) Gets a byte at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffer- Returns:
- The byte at the specified index
- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 1is greater thanthis.capacity
-
getUnsignedByte
short getUnsignedByte(int index) Gets an unsigned byte at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffer- Returns:
- an unsigned byte at the specified absolute
index - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 1is greater thanthis.capacity
-
getShort
short getShort(int index) Gets a 16-bit short integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffer- Returns:
- a 16-bit short integer at the specified absolute
index - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 2is greater thanthis.capacity
-
getUnsignedShort
int getUnsignedShort(int index) Gets an unsigned 16-bit short integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffer- Returns:
- an unsigned 16-bit short integer
- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 2is greater thanthis.capacity
-
getInt
int getInt(int index) Gets a 32-bit integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffer- Returns:
- a 32-bit integer at the specified absolute
index - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 4is greater thanthis.capacity
-
getUnsignedInt
long getUnsignedInt(int index) Gets an unsigned 32-bit integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- The index into this buffer- Returns:
- an unsigned 32-bit integer at the specified absolute
index - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 4is greater thanthis.capacity
-
getLong
long getLong(int index) Gets a 64-bit long integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffer- Returns:
- a 64-bit long integer at the specified absolute
index - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 8is greater thanthis.capacity
-
getBytes
Transfers this buffer's data to the specified destination starting at the specified absoluteindexuntil the destination becomes non-writable. This method is basically same withgetBytes(int, ActiveMQBuffer, int, int), except that this method increases thewriterIndexof the destination by the number of the transferred bytes whilegetBytes(int, ActiveMQBuffer, int, int)does not. This method does not modifyreaderIndexorwriterIndexof the source buffer (i.e.this).- Parameters:
index- Index into the bufferdst- The destination buffer- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0or ifindex + dst.writableBytesis greater thanthis.capacity
-
getBytes
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 thewriterIndexof the destination by the number of the transferred bytes whilegetBytes(int, ActiveMQBuffer, int, int)does not. This method does not modifyreaderIndexorwriterIndexof 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 specifiedindexis less than0, ifindex + lengthis greater thanthis.capacity, or iflengthis greater thandst.writableBytes
-
getBytes
Transfers 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.- 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 specifiedindexis less than0, if the specifieddstIndexis less than0, ifindex + lengthis greater thanthis.capacity, or ifdstIndex + lengthis 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 modifyreaderIndexorwriterIndexof this buffer- Parameters:
index- Index into the bufferdst- The destination buffer- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0or ifindex + dst.lengthis 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 modifyreaderIndexorwriterIndexof 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 specifiedindexis less than0, if the specifieddstIndexis less than0, ifindex + lengthis greater thanthis.capacity, or ifdstIndex + lengthis greater thandst.length
-
getBytes
Transfers 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.- Parameters:
index- Index into the bufferdst- The destination buffer- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0or ifindex + dst.remaining()is greater thanthis.capacity
-
getChar
char getChar(int index) Gets a char at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffer- Returns:
- a char at the specified absolute
index - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 2is greater thanthis.capacity
-
getFloat
float getFloat(int index) Gets a float at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffer- Returns:
- a float at the specified absolute
index - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 4is greater thanthis.capacity
-
getDouble
double getDouble(int index) Gets a double at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffer- Returns:
- a double at the specified absolute
index - Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 8is greater thanthis.capacity
-
setByte
void setByte(int index, byte value) Sets the specified byte at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffervalue- The specified byte- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 1is greater thanthis.capacity
-
setShort
void setShort(int index, short value) Sets the specified 16-bit short integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffervalue- The specified 16-bit short integer- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 2is greater thanthis.capacity
-
setInt
void setInt(int index, int value) Sets the specified 32-bit integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffervalue- The specified 32-bit integer- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 4is greater thanthis.capacity
-
setLong
void setLong(int index, long value) Sets the specified 64-bit long integer at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffervalue- The specified 64-bit long integer- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 8is greater thanthis.capacity
-
setBytes
Transfers the specified source buffer's data to this buffer starting at the specified absoluteindexuntil the destination becomes unreadable. This method is basically same withsetBytes(int, ActiveMQBuffer, int, int), except that this method increases thereaderIndexof the source buffer by the number of the transferred bytes whilegetBytes(int, ActiveMQBuffer, int, int)does not. This method does not modifyreaderIndexorwriterIndexof the source buffer (i.e.this).- Parameters:
index- Index into the buffersrc- The source buffer- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0or ifindex + src.readableBytesis greater thanthis.capacity
-
setBytes
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 thereaderIndexof the source buffer by the number of the transferred bytes whilegetBytes(int, ActiveMQBuffer, int, int)does not. This method does not modifyreaderIndexorwriterIndexof 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 specifiedindexis less than0, ifindex + lengthis greater thanthis.capacity, or iflengthis greater thansrc.readableBytes
-
setBytes
Transfers 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.- 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 specifiedindexis less than0, if the specifiedsrcIndexis less than0, ifindex + lengthis greater thanthis.capacity, or ifsrcIndex + lengthis 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 modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffersrc- The source buffer- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0or ifindex + src.lengthis 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 modifyreaderIndexorwriterIndexof 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 specifiedindexis less than0, if the specifiedsrcIndexis less than0, ifindex + lengthis greater thanthis.capacity, or ifsrcIndex + lengthis greater thansrc.length
-
setBytes
Transfers 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.- Parameters:
index- Index into the buffersrc- The source buffer- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0or ifindex + src.remaining()is greater thanthis.capacity
-
setChar
void setChar(int index, char value) Sets the specified char at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffervalue- The specified char- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 2is greater thanthis.capacity
-
setFloat
void setFloat(int index, float value) Sets the specified float at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffervalue- The specified float- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 4is greater thanthis.capacity
-
setDouble
void setDouble(int index, double value) Sets the specified double at the specified absoluteindexin this buffer. This method does not modifyreaderIndexorwriterIndexof this buffer.- Parameters:
index- Index into the buffervalue- The specified double- Throws:
IndexOutOfBoundsException- if the specifiedindexis less than0orindex + 8is greater thanthis.capacity
-
readByte
byte readByte()Gets a byte at the currentreaderIndexand increases thereaderIndexby1in this buffer.- Specified by:
readBytein interfaceDataInput- Returns:
- a byte at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than1
-
readUnsignedByte
int readUnsignedByte()Gets an unsigned byte at the currentreaderIndexand increases thereaderIndexby1in this buffer.- Specified by:
readUnsignedBytein interfaceDataInput- Returns:
- an unsigned byte at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than1
-
readShort
short readShort()Gets a 16-bit short integer at the currentreaderIndexand increases thereaderIndexby2in this buffer.- Specified by:
readShortin interfaceDataInput- Returns:
- a 16-bit short integer at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than2
-
readUnsignedShort
int readUnsignedShort()Gets an unsigned 16-bit short integer at the currentreaderIndexand increases thereaderIndexby2in this buffer.- Specified by:
readUnsignedShortin interfaceDataInput- Returns:
- an unsigned 16-bit short integer at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than2
-
readInt
int readInt()Gets a 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.- Specified by:
readIntin interfaceDataInput- Returns:
- a 32-bit integer at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than4
-
readNullableInt
Integer readNullableInt()Gets a (potentiallynull) 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.- Returns:
- a (potentially
null) 32-bit integer at the currentreaderIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than4
-
readUnsignedInt
long readUnsignedInt()Gets an unsigned 32-bit integer at the currentreaderIndexand increases thereaderIndexby4in this buffer.- Returns:
- an unsigned 32-bit integer at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than4
-
readLong
long readLong()Gets a 64-bit integer at the currentreaderIndexand increases thereaderIndexby8in this buffer.- Specified by:
readLongin interfaceDataInput- Returns:
- a 64-bit integer at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than8
-
readNullableLong
Long readNullableLong()Gets a (potentiallynull) 64-bit integer at the currentreaderIndexand increases thereaderIndexby8in this buffer.- Returns:
- a (potentially
null) 64-bit integer at the currentreaderIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than8
-
readChar
char readChar()Gets a char at the currentreaderIndexand increases thereaderIndexby2in this buffer.- Specified by:
readCharin interfaceDataInput- Returns:
- a char at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than2
-
readFloat
float readFloat()Gets a float at the currentreaderIndexand increases thereaderIndexby4in this buffer.- Specified by:
readFloatin interfaceDataInput- Returns:
- a float at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than4
-
readDouble
double readDouble()Gets a double at the currentreaderIndexand increases thereaderIndexby8in this buffer.- Specified by:
readDoublein interfaceDataInput- Returns:
- a double at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than8
-
readBoolean
boolean readBoolean()Gets a boolean at the currentreaderIndexand increases thereaderIndexby1in this buffer.- Specified by:
readBooleanin interfaceDataInput- Returns:
- a boolean at the current
readerIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis less than1
-
readNullableBoolean
Boolean readNullableBoolean()Gets a (potentiallynull) boolean at the currentreaderIndexand increases thereaderIndexby1in this buffer.- Returns:
- a (potentially
null) boolean at the currentreaderIndex - Throws:
IndexOutOfBoundsException- ifthis.readableBytesis 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
Returns a new slice of this buffer's sub-region starting at the currentreaderIndexand increases thereaderIndexby the size of the new slice (=length).- Parameters:
length- the size of the new slice- Returns:
- the newly created slice
- Throws:
IndexOutOfBoundsException- iflengthis greater thanthis.readableBytes
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination becomes non-writable, and increases thereaderIndexby the number of the transferred bytes. This method is basically same withreadBytes(ActiveMQBuffer, int, int), except that this method increases thewriterIndexof the destination by the number of the transferred bytes whilereadBytes(ActiveMQBuffer, int, int)does not.- Parameters:
dst- The destination buffer- Throws:
IndexOutOfBoundsException- ifdst.writableBytesis greater thanthis.readableBytes
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=length). This method is basically same withreadBytes(ActiveMQBuffer, int, int), except that this method increases thewriterIndexof 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- iflengthis greater thanthis.readableBytesor iflengthis greater thandst.writableBytes
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby 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 specifieddstIndexis less than0, iflengthis greater thanthis.readableBytes, or ifdstIndex + lengthis greater thandst.capacity
-
readBytes
void readBytes(byte[] dst) Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby the number of the transferred bytes (=dst.length).- Parameters:
dst- The destination buffer- Throws:
IndexOutOfBoundsException- ifdst.lengthis greater thanthis.readableBytes
-
readBytes
void readBytes(byte[] dst, int dstIndex, int length) Transfers this buffer's data to the specified destination starting at the currentreaderIndexand increases thereaderIndexby 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 specifieddstIndexis less than0, iflengthis greater thanthis.readableBytes, or ifdstIndex + lengthis greater thandst.length
-
readBytes
Transfers this buffer's data to the specified destination starting at the currentreaderIndexuntil the destination's position reaches its limit, and increases thereaderIndexby 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 currentreaderIndexby the specifiedlengthin this buffer.- Specified by:
skipBytesin interfaceDataInput- Parameters:
length- The number of bytes to skip- Throws:
IndexOutOfBoundsException- iflengthis greater thanthis.readableBytes
-
writeByte
void writeByte(byte value) Sets the specified byte at the currentwriterIndexand increases thewriterIndexby1in this buffer.- Parameters:
value- The specified byte- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than1
-
writeShort
void writeShort(short value) Sets the specified 16-bit short integer at the currentwriterIndexand increases thewriterIndexby2in this buffer.- Parameters:
value- The specified 16-bit short integer- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than2
-
writeInt
void writeInt(int value) Sets the specified 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.- Parameters:
value- The specified 32-bit integer- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than4
-
writeNullableInt
Sets the specified (potentiallynull) 32-bit integer at the currentwriterIndexand increases thewriterIndexby4in this buffer.- Parameters:
value- The specified (potentiallynull) 32-bit integer- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than4
-
writeLong
void writeLong(long value) Sets the specified 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.- Parameters:
value- The specified 64-bit long integer- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than8
-
writeNullableLong
Sets the specified (potentiallynull) 64-bit long integer at the currentwriterIndexand increases thewriterIndexby8in this buffer.- Parameters:
value- The specified (potentiallynull) 64-bit long integer- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than8
-
writeChar
void writeChar(char chr) Sets the specified char at the currentwriterIndexand increases thewriterIndexby2in this buffer.- Parameters:
chr- The specified char- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than2
-
writeFloat
void writeFloat(float value) Sets the specified float at the currentwriterIndexand increases thewriterIndexby4in this buffer.- Parameters:
value- The specified float- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than4
-
writeDouble
void writeDouble(double value) Sets the specified double at the currentwriterIndexand increases thewriterIndexby8in this buffer.- Parameters:
value- The specified double- Throws:
IndexOutOfBoundsException- ifthis.writableBytesis less than8
-
writeBoolean
void writeBoolean(boolean val) Sets the specified boolean at the currentwriterIndex- Parameters:
val- The specified boolean
-
writeNullableBoolean
Sets the specified (potentiallynull) Boolean at the currentwriterIndex- Parameters:
val- The specified boolean
-
writeNullableSimpleString
Sets the specified SimpleString (potentiallynull) at the currentwriterIndex- Parameters:
val- The specified SimpleString
-
writeNullableString
Sets the specified String (potentiallynull) at the currentwriterIndex- Parameters:
val- The specified String
-
writeSimpleString
Sets the specified non-null SimpleString at the currentwriterIndex- Parameters:
val- The specified non-null SimpleString
-
writeString
Sets the specified non-null String at the currentwriterIndex- Parameters:
val- The specified non-null String
-
writeUTF
Sets the specified UTF-8 String at the currentwriterIndex- Parameters:
utf- The specified UTF-8 String
-
writeBytes
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=length). This method is basically same withwriteBytes(ActiveMQBuffer, int, int), except that this method increases thereaderIndexof 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- iflengthis greater thanthis.writableBytesor iflengthis greater thensrc.readableBytes
-
writeBytes
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby 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 specifiedsrcIndexis less than0, ifsrcIndex + lengthis greater thansrc.capacity, or iflengthis greater thanthis.writableBytes
-
writeBytes
void writeBytes(byte[] src) Transfers the specified source array's data to this buffer starting at the currentwriterIndexand increases thewriterIndexby the number of the transferred bytes (=src.length).- Parameters:
src- The source buffer- Throws:
IndexOutOfBoundsException- ifsrc.lengthis 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 currentwriterIndexand increases thewriterIndexby 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 specifiedsrcIndexis less than0, ifsrcIndex + lengthis greater thansrc.length, or iflengthis greater thanthis.writableBytes
-
writeBytes
Transfers the specified source buffer's data to this buffer starting at the currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby 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 currentwriterIndexuntil the source buffer's position reaches its limit, and increases thewriterIndexby 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 modifyreaderIndexorwriterIndexof this buffer.- Returns:
- a copy of this buffer's readable bytes
-
copy
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 modifyreaderIndexorwriterIndexof 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 modifyreaderIndexorwriterIndexof this buffer.- Returns:
- a slice of this buffer's readable bytes
-
slice
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 modifyreaderIndexorwriterIndexof 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 modifyreaderIndexorwriterIndexof 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 modifyreaderIndexorwriterIndexof this buffer.- Returns:
- A converted NIO ByteBuffer
-
toByteBuffer
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 modifyreaderIndexorwriterIndexof 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
-