FlatBuffers
An open source project by FPL.
|
Helper class that builds FlexBuffers. More...
Helper class that builds FlexBuffers.
This class presents all necessary APIs to create FlexBuffers. A ByteBuffer
will be used to store the data. It can be created internally, or passed down in the constructor.
There are some limitations when compared to original implementation in C++. Most notably:
No support for mutations (might change in the future).
Buffer size limited to Integer#MAX_VALUE
Since Java does not support unsigned type, all unsigned operations accepts an immediate higher representation of similar type.
Public Member Functions | |
void | clear () |
Reset the FlexBuffersBuilder by purging all data that it holds. | |
int | endMap (String key, int start) |
Finishes a map, but writing the information in the buffer. More... | |
int | endVector (String key, int start, boolean typed, boolean fixed) |
Finishes a vector, but writing the information in the buffer. More... | |
ByteBuffer | finish () |
Finish writing the message into the buffer. More... | |
FlexBuffersBuilder () | |
Constructs a newly allocated. More... | |
FlexBuffersBuilder (ByteBuffer bb) | |
Constructs a newly allocated. More... | |
FlexBuffersBuilder (ByteBuffer bb, int flags) | |
Constructs a newly allocated. More... | |
FlexBuffersBuilder (int bufSize) | |
Constructs a newly allocated. More... | |
FlexBuffersBuilder (ReadWriteBuf bb, int flags) | |
ReadWriteBuf | getBuffer () |
Return ByteBuffer containing FlexBuffer message. More... | |
int | putBlob (byte[] value) |
Adds a byte array into the message. More... | |
int | putBlob (String key, byte[] val) |
Adds a byte array into the message. More... | |
void | putBoolean (boolean val) |
Insert a single boolean into the buffer. More... | |
void | putBoolean (String key, boolean val) |
Insert a single boolean into the buffer. More... | |
void | putFloat (double value) |
Adds a 64-bit float into the buff. More... | |
void | putFloat (float value) |
Adds a 32-bit float into the buff. More... | |
void | putFloat (String key, double val) |
Adds a 64-bit float into the buff. More... | |
void | putFloat (String key, float val) |
Adds a 32-bit float into the buff. More... | |
void | putInt (int val) |
Adds a integer into the buff. More... | |
void | putInt (long value) |
Adds a 64-bit integer into the buff. More... | |
void | putInt (String key, int val) |
Adds a integer into the buff. More... | |
void | putInt (String key, long val) |
Adds a integer into the buff. More... | |
int | putString (String key, String val) |
Adds a String into the buffer. More... | |
int | putString (String value) |
Adds a String into the buffer. More... | |
void | putUInt (int value) |
Adds a unsigned integer into the buff. More... | |
void | putUInt (long value) |
Adds a unsigned integer (stored in a signed 64-bit integer) into the buff. More... | |
void | putUInt64 (BigInteger value) |
Adds a 64-bit unsigned integer (stored as BigInteger) into the buff. More... | |
int | startMap () |
Start a new map in the buffer. More... | |
int | startVector () |
Start a new vector in the buffer. More... | |
Static Public Attributes | |
static final int | BUILDER_FLAG_NONE = 0 |
No keys or strings will be shared. | |
static final int | BUILDER_FLAG_SHARE_ALL = 7 |
Reserved for the future. | |
static final int | BUILDER_FLAG_SHARE_KEY_VECTORS = 4 |
Reserved for the future. | |
static final int | BUILDER_FLAG_SHARE_KEYS = 1 |
Keys will be shared between elements. More... | |
static final int | BUILDER_FLAG_SHARE_KEYS_AND_STRINGS = 3 |
Strings and keys will be shared between elements. | |
static final int | BUILDER_FLAG_SHARE_STRINGS = 2 |
Strings will be shared between elements. More... | |
|
inline |
Constructs a newly allocated.
with BUILDER_FLAG_SHARE_KEYS set.
bufSize | size of buffer in bytes. |
|
inline |
|
inline |
Constructs a newly allocated.
.
bb | ByteBuffer that will hold the message |
flags | Share flags |
|
inline |
Constructs a newly allocated.
. By default same keys will be serialized only once
bb | ByteBuffer that will hold the message |
|
inline |
Finishes a map, but writing the information in the buffer.
key | key used to store element in map |
start | reference for begining of the map. Returned by startMap() |
|
inline |
Finishes a vector, but writing the information in the buffer.
key | key used to store element in map |
start | reference for begining of the vector. Returned by startVector() |
typed | boolean indicating whether vector is typed |
fixed | boolean indicating whether vector is fixed |
|
inline |
Finish writing the message into the buffer.
After that no other element must be inserted into the buffer. Also, you must call this function before start using the FlexBuffer message
ByteBuffer
containing the FlexBuffer message
|
inline |
Return ByteBuffer
containing FlexBuffer message.
must be called before calling this function otherwise an assert will trigger.
ByteBuffer
with finished message
|
inline |
Adds a byte array into the message.
value | byte array |
|
inline |
Adds a byte array into the message.
key | key used to store element in map |
value | byte array |
|
inline |
Insert a single boolean into the buffer.
val | true or false |
|
inline |
Insert a single boolean into the buffer.
key | key used to store element in map |
val | true or false |
|
inline |
Adds a 64-bit float into the buff.
value | float representing value |
|
inline |
Adds a 32-bit float into the buff.
value | float representing value |
|
inline |
Adds a 64-bit float into the buff.
key | key used to store element in map |
value | float representing value |
|
inline |
Adds a 32-bit float into the buff.
key | key used to store element in map |
value | float representing value |
|
inline |
Adds a integer into the buff.
val | integer |
|
inline |
Adds a 64-bit integer into the buff.
value | integer |
|
inline |
Adds a integer into the buff.
key | key used to store element in map |
val | integer |
|
inline |
Adds a integer into the buff.
key | key used to store element in map |
val | 64-bit integer |
|
inline |
Adds a String into the buffer.
key | key used to store element in map |
value | string |
|
inline |
Adds a String into the buffer.
value | string |
|
inline |
Adds a unsigned integer into the buff.
value | integer representing unsigned value |
|
inline |
Adds a unsigned integer (stored in a signed 64-bit integer) into the buff.
value | integer representing unsigned value |
|
inline |
Adds a 64-bit unsigned integer (stored as BigInteger) into the buff.
Warning: This operation might be very slow.
value | integer representing unsigned value |
|
inline |
Start a new map in the buffer.
|
inline |
Start a new vector in the buffer.
|
static |
Keys will be shared between elements.
Identical keys will only be serialized once, thus possibly saving space. But serialization performance might be slower and consumes more memory.
|
static |
Strings will be shared between elements.
Identical strings will only be serialized once, thus possibly saving space. But serialization performance might be slower and consumes more memory. This is ideal if you expect many repeated strings on the message.