Package io.objectbox.flatbuffers
Interface ReadWriteBuf
- All Superinterfaces:
ReadBuf
- All Known Implementing Classes:
ArrayReadWriteBuf
,ByteBufferReadWriteBuf
Interface to represent a read-write buffer. This interface will be used to access and write
FlexBuffers message.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears (resets) the buffer so that it can be reused.int
limit()
Defines the size of the message in the buffer.void
put
(byte value) Write a byte into the buffer atwritePosition()
.void
put
(byte[] value, int start, int length) Put an array of bytes into the buffer atwritePosition()
.void
putBoolean
(boolean value) Put a boolean into the buffer atwritePosition()
.void
putDouble
(double value) Write a 64-bit float into the buffer atwritePosition()
.void
putFloat
(float value) Write a 32-bit float into the buffer atwritePosition()
.void
putInt
(int value) Write a 32-bit into in the buffer atwritePosition()
.void
putLong
(long value) Write a 64-bit into in the buffer atwritePosition()
.void
putShort
(short value) Write a 16-bit into in the buffer atwritePosition()
.boolean
requestCapacity
(int capacity) Request capacity of the buffer.void
set
(int index, byte value) Read a byte from data.void
set
(int index, byte[] value, int start, int length) Write an array of bytes into the buffer.void
setBoolean
(int index, boolean value) Write boolean into a given position on the buffer.void
setDouble
(int index, double value) Read a 64-bit float from data.void
setFloat
(int index, float value) Read a 32-bit float from data.void
setInt
(int index, int value) Read a 32-bit int from data.void
setLong
(int index, long value) Read a 64-bit long from data.void
setShort
(int index, short value) Read a short from data.int
-
Method Details
-
clear
void clear()Clears (resets) the buffer so that it can be reused. Write position will be set to the start. -
putBoolean
void putBoolean(boolean value) Put a boolean into the buffer atwritePosition()
. Booleans as stored as single byte. Write position will be incremented. -
put
void put(byte[] value, int start, int length) Put an array of bytes into the buffer atwritePosition()
. Write position will be incremented.- Parameters:
value
- the data to be copiedstart
- initial position on value to be copiedlength
- amount of bytes to be copied
-
put
void put(byte value) Write a byte into the buffer atwritePosition()
. Write position will be incremented. -
putShort
void putShort(short value) Write a 16-bit into in the buffer atwritePosition()
. Write position will be incremented. -
putInt
void putInt(int value) Write a 32-bit into in the buffer atwritePosition()
. Write position will be incremented. -
putLong
void putLong(long value) Write a 64-bit into in the buffer atwritePosition()
. Write position will be incremented. -
putFloat
void putFloat(float value) Write a 32-bit float into the buffer atwritePosition()
. Write position will be incremented. -
putDouble
void putDouble(double value) Write a 64-bit float into the buffer atwritePosition()
. Write position will be incremented. -
setBoolean
void setBoolean(int index, boolean value) Write boolean into a given position on the buffer. Booleans as stored as single byte.- Parameters:
index
- position of the element in buffer
-
set
void set(int index, byte value) Read a byte from data.- Parameters:
index
- position of the element in the buffer
-
set
void set(int index, byte[] value, int start, int length) Write an array of bytes into the buffer.- Parameters:
index
- initial position of the buffer to be writtenvalue
- the data to be copiedstart
- initial position on value to be copiedlength
- amount of bytes to be copied
-
setShort
void setShort(int index, short value) Read a short from data.- Parameters:
index
- position of the element in ReadBuf
-
setInt
void setInt(int index, int value) Read a 32-bit int from data.- Parameters:
index
- position of the element in ReadBuf
-
setLong
void setLong(int index, long value) Read a 64-bit long from data.- Parameters:
index
- position of the element in ReadBuf
-
setFloat
void setFloat(int index, float value) Read a 32-bit float from data.- Parameters:
index
- position of the element in ReadBuf
-
setDouble
void setDouble(int index, double value) Read a 64-bit float from data.- Parameters:
index
- position of the element in ReadBuf
-
writePosition
int writePosition() -
limit
int limit()Defines the size of the message in the buffer. It also determines last position that buffer can be read or write. Last byte to be accessed is in positionlimit() -1
. -
requestCapacity
boolean requestCapacity(int capacity) Request capacity of the buffer. In case buffer is already larger than the requested, this method will just return true. Otherwise It might try to resize the buffer.- Returns:
- true if buffer is able to offer the requested capacity
-