Package io.objectbox.flatbuffers
Interface ReadBuf
- All Known Subinterfaces:
ReadWriteBuf
- All Known Implementing Classes:
ArrayReadWriteBuf,ByteBufferReadWriteBuf
public interface ReadBuf
Represent a chunk of data, where FlexBuffers will read from.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]data()Expose ReadBuf as an array of bytes.byteget(int index) Read a byte from data.booleangetBoolean(int index) Read boolean from data.doublegetDouble(int index) Read a 64-bit float from data.floatgetFloat(int index) Read a 32-bit float from data.intgetInt(int index) Read a 32-bit int from data.longgetLong(int index) Read a 64-bit long from data.shortgetShort(int index) Read a short from data.getString(int start, int size) Read an UTF-8 string from data.intlimit()Defines the size of the message in the buffer.
-
Method Details
-
getBoolean
boolean getBoolean(int index) Read boolean from data. Booleans as stored as single byte- Parameters:
index- position of the element in ReadBuf- Returns:
- boolean element
-
get
byte get(int index) Read a byte from data.- Parameters:
index- position of the element in ReadBuf- Returns:
- a byte
-
getShort
short getShort(int index) Read a short from data.- Parameters:
index- position of the element in ReadBuf- Returns:
- a short
-
getInt
int getInt(int index) Read a 32-bit int from data.- Parameters:
index- position of the element in ReadBuf- Returns:
- an int
-
getLong
long getLong(int index) Read a 64-bit long from data.- Parameters:
index- position of the element in ReadBuf- Returns:
- a long
-
getFloat
float getFloat(int index) Read a 32-bit float from data.- Parameters:
index- position of the element in ReadBuf- Returns:
- a float
-
getDouble
double getDouble(int index) Read a 64-bit float from data.- Parameters:
index- position of the element in ReadBuf- Returns:
- a double
-
getString
Read an UTF-8 string from data.- Parameters:
start- initial element of the stringsize- size of the string in bytes.- Returns:
- a
String
-
data
byte[] data()Expose ReadBuf as an array of bytes. This method is meant to be as efficient as possible, so for a array-backed ReadBuf, it should return its own internal data. In case access to internal data is not possible, a copy of the data into an array of bytes might occur.- Returns:
- ReadBuf as an array of bytes
-
limit
int limit()Defines the size of the message in the buffer. It also determines last position that buffer can be read. Last byte to be accessed is in positionlimit() -1.- Returns:
- indicate last position
-