Package org.apache.qpid.protonj2.buffer
Interface ProtonBufferAccessors
- All Known Subinterfaces:
- ProtonBuffer,- ProtonCompositeBuffer
- All Known Implementing Classes:
- Netty4ToProtonBufferAdapter,- Netty5ToProtonBufferAdapter,- ProtonByteArrayBuffer,- ProtonCompositeBufferImpl
public interface ProtonBufferAccessors
Interface for any buffer access implementation which provides consistent read
 and write APIs for primitive values.  These APIs are useful for serialization
 and de-serialization APIs which need to write at a primitive level.
- 
Method SummaryModifier and TypeMethodDescriptiondefault booleangetBoolean(int index) Reads a single byte at the given index and returns it as a boolean value, without modification to the target buffer read offset.bytegetByte(int index) Reads a single byte at the given index and returns it without modification to the target buffer read offset.chargetChar(int index) Gets a 2-byte char from the specified index, this method will not modify the read or write index.default doublegetDouble(int index) Gets a double from the specified index, this method will not modify the read or write index.default floatgetFloat(int index) Gets a float from the specified index, this method will not modify the read or write index.intgetInt(int index) Gets a int from the specified index, this method will not modify the read or write index.longgetLong(int index) Gets a long from the specified index, this method will not modify the read or write index.shortgetShort(int index) Gets a short from the specified index, this method will not modify the read or write index.default intgetUnsignedByte(int index) Gets a unsigned byte from the specified index, this method will not modify the read or write index.default longgetUnsignedInt(int index) Gets a unsigned int from the specified index, this method will not modify the read or write index.default intgetUnsignedShort(int index) Gets a unsigned short from the specified index, this method will not modify the read or write index.default booleanReads a boolean value from the buffer and advances the read index by one.bytereadByte()Reads one byte from the buffer and advances the read index by one.charreadChar()Reads a character value from the buffer and advances the read index by four.default doubleReads a double value from the buffer and advances the read index by eight.default floatReads a float value from the buffer and advances the read index by four.intreadInt()Reads a integer value from the buffer and advances the read index by four.longreadLong()Reads a long value from the buffer and advances the read index by eight.shortReads a short value from the buffer and advances the read index by two.default intReads one byte from the buffer and advances the read index by one.default longReads a unsigned integer value from the buffer and advances the read index by four.default intReads an integer value from the buffer that represent the unsigned value of the short and advances the read index by two.default ProtonBuffersetBoolean(int index, boolean value) Sets the boolean value at the given write index in this buffer's backing data store.setByte(int index, byte value) Sets the byte value at the given write index in this buffer's backing data store.setChar(int index, char value) Sets the char value at the given write index in this buffer's backing data store.default ProtonBuffersetDouble(int index, double value) Sets the double value at the given write index in this buffer's backing data store.default ProtonBuffersetFloat(int index, float value) Sets the float value at the given write index in this buffer's backing data store.setInt(int index, int value) Sets the int value at the given write index in this buffer's backing data store.setLong(int index, long value) Sets the long value at the given write index in this buffer's backing data store.setShort(int index, short value) Sets the short value at the given write index in this buffer's backing data store.default ProtonBuffersetUnsignedByte(int index, int value) Sets the unsigned byte value at the given write index in this buffer's backing data store.default ProtonBuffersetUnsignedInt(int index, long value) Sets the long value at the given write index in this buffer's backing data store.default ProtonBuffersetUnsignedShort(int index, int value) Sets the short value at the given write index in this buffer's backing data store.default ProtonBufferwriteBoolean(boolean value) Writes a single boolean to the buffer and advances the write index by one.writeByte(byte value) Writes a single byte to the buffer and advances the write index by one.writeChar(char value) Writes a single character to the buffer and advances the write index by four.default ProtonBufferwriteDouble(double value) Writes a single double to the buffer and advances the write index by eight.default ProtonBufferwriteFloat(float value) Writes a single float to the buffer and advances the write index by four.writeInt(int value) Writes a single integer to the buffer and advances the write index by four.writeLong(long value) Writes a single long to the buffer and advances the write index by eight.writeShort(short value) Writes a single short to the buffer and advances the write index by two.default ProtonBufferwriteUnsignedByte(int value) Writes a single byte to the buffer and advances the write index by one.default ProtonBufferwriteUnsignedInt(long value) Writes a single unsigned int to the buffer and advances the write index by four.default ProtonBufferwriteUnsignedShort(int value) Writes a single short to the buffer using the input integer value and advances the write index by two.
- 
Method Details- 
getBytebyte getByte(int index) Reads a single byte at the given index and returns it without modification to the target buffer read offset.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setByteSets the byte value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readBytebyte readByte()Reads one byte from the buffer and advances the read index by one.- Returns:
- a single byte from the ProtonBuffer.
- Throws:
- IndexOutOfBoundsException- if there is no readable bytes left in the buffer.
 
- 
writeByteWrites a single byte to the buffer and advances the write index by one.- Parameters:
- value- The byte to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getBooleandefault boolean getBoolean(int index) Reads a single byte at the given index and returns it as a boolean value, without modification to the target buffer read offset.- Parameters:
- index- The index where the value should be read from.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setBooleanSets the boolean value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readBooleandefault boolean readBoolean()Reads a boolean value from the buffer and advances the read index by one.- Returns:
- boolean value read from the buffer.
- Throws:
- IndexOutOfBoundsException- if a value cannot be read from the buffer.
 
- 
writeBooleanWrites a single boolean to the buffer and advances the write index by one.- Parameters:
- value- The boolean to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getUnsignedBytedefault int getUnsignedByte(int index) Gets a unsigned byte from the specified index, this method will not modify the read or write index.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setUnsignedByteSets the unsigned byte value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readUnsignedBytedefault int readUnsignedByte()Reads one byte from the buffer and advances the read index by one.- Returns:
- a single byte from the ProtonBuffer.
- Throws:
- IndexOutOfBoundsException- if there is no readable bytes left in the buffer.
 
- 
writeUnsignedByteWrites a single byte to the buffer and advances the write index by one.- Parameters:
- value- The byte to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getCharchar getChar(int index) Gets a 2-byte char from the specified index, this method will not modify the read or write index.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setCharSets the char value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readCharchar readChar()Reads a character value from the buffer and advances the read index by four.- Returns:
- char value read from the buffer.
- Throws:
- IndexOutOfBoundsException- if a value cannot be read from the buffer.
 
- 
writeCharWrites a single character to the buffer and advances the write index by four.- Parameters:
- value- The char to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getShortshort getShort(int index) Gets a short from the specified index, this method will not modify the read or write index.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setShortSets the short value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readShortshort readShort()Reads a short value from the buffer and advances the read index by two.- Returns:
- short value read from the buffer.
- Throws:
- IndexOutOfBoundsException- if a value cannot be read from the buffer.
 
- 
writeShortWrites a single short to the buffer and advances the write index by two.- Parameters:
- value- The short to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getUnsignedShortdefault int getUnsignedShort(int index) Gets a unsigned short from the specified index, this method will not modify the read or write index.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setUnsignedShortSets the short value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readUnsignedShortdefault int readUnsignedShort()Reads an integer value from the buffer that represent the unsigned value of the short and advances the read index by two.- Returns:
- unsigned short value read from the buffer.
- Throws:
- IndexOutOfBoundsException- if a value cannot be read from the buffer.
 
- 
writeUnsignedShortWrites a single short to the buffer using the input integer value and advances the write index by two.- Parameters:
- value- The integer to write into the buffer as an unsigned short.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getIntint getInt(int index) Gets a int from the specified index, this method will not modify the read or write index.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setIntSets the int value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readIntint readInt()Reads a integer value from the buffer and advances the read index by four.- Returns:
- integer value read from the buffer.
- Throws:
- IndexOutOfBoundsException- if a value cannot be read from the buffer.
 
- 
writeIntWrites a single integer to the buffer and advances the write index by four.- Parameters:
- value- The integer to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getUnsignedIntdefault long getUnsignedInt(int index) Gets a unsigned int from the specified index, this method will not modify the read or write index.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setUnsignedIntSets the long value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readUnsignedIntdefault long readUnsignedInt()Reads a unsigned integer value from the buffer and advances the read index by four.- Returns:
- long value read from the buffer.
- Throws:
- IndexOutOfBoundsException- if a value cannot be read from the buffer.
 
- 
writeUnsignedIntWrites a single unsigned int to the buffer and advances the write index by four.- Parameters:
- value- The long to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getLonglong getLong(int index) Gets a long from the specified index, this method will not modify the read or write index.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setLongSets the long value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readLonglong readLong()Reads a long value from the buffer and advances the read index by eight.- Returns:
- long value read from the buffer.
- Throws:
- IndexOutOfBoundsException- if a value cannot be read from the buffer.
 
- 
writeLongWrites a single long to the buffer and advances the write index by eight.- Parameters:
- value- The long to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getFloatdefault float getFloat(int index) Gets a float from the specified index, this method will not modify the read or write index.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setFloatSets the float value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readFloatdefault float readFloat()Reads a float value from the buffer and advances the read index by four.- Returns:
- float value read from the buffer.
- Throws:
- IndexOutOfBoundsException- if a value cannot be read from the buffer.
 
- 
writeFloatWrites a single float to the buffer and advances the write index by four.- Parameters:
- value- The float to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
- 
getDoubledefault double getDouble(int index) Gets a double from the specified index, this method will not modify the read or write index.- Parameters:
- index- The index into the buffer where the value should be read.
- Returns:
- the value read from the given index.
- Throws:
- IndexOutOfBoundsException- if the index is negative or past the current buffer capacity.
 
- 
setDoubleSets the double value at the given write index in this buffer's backing data store.- Parameters:
- index- The index to start the write from.
- value- The value to write at the given index.
- Returns:
- a reference to this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if the index is negative or the write would exceed capacity.
 
- 
readDoubledefault double readDouble()Reads a double value from the buffer and advances the read index by eight.- Returns:
- double value read from the buffer.
- Throws:
- IndexOutOfBoundsException- if a value cannot be read from the buffer.
 
- 
writeDoubleWrites a single double to the buffer and advances the write index by eight.- Parameters:
- value- The double to write into the buffer.
- Returns:
- this ProtonBuffer for chaining.
- Throws:
- IndexOutOfBoundsException- if there is no room in the buffer for this write operation.
 
 
-