Class FlexBuffers

java.lang.Object
io.objectbox.flatbuffers.FlexBuffers

public class FlexBuffers extends Object
This class can be used to parse FlexBuffer messages.

For generating FlexBuffer messages, use FlexBuffersBuilder.

Example of usage:

 ReadBuf bb = ... // load message from file or network
 FlexBuffers.Reference r = FlexBuffers.getRoot(bb); // Reads the root element
 FlexBuffers.Map map = r.asMap(); // We assumed root object is a map
 System.out.println(map.get("name").asString()); // prints element with key "name"
 
  • Field Details

    • FBT_NULL

      public static final int FBT_NULL
      Represent a null type
      See Also:
    • FBT_INT

      public static final int FBT_INT
      Represent a signed integer type
      See Also:
    • FBT_UINT

      public static final int FBT_UINT
      Represent a unsigned type
      See Also:
    • FBT_FLOAT

      public static final int FBT_FLOAT
      Represent a float type
      See Also:
    • FBT_KEY

      public static final int FBT_KEY
      Represent a key to a map type
      See Also:
    • FBT_STRING

      public static final int FBT_STRING
      Represent a string type
      See Also:
    • FBT_INDIRECT_INT

      public static final int FBT_INDIRECT_INT
      Represent a indirect signed integer type
      See Also:
    • FBT_INDIRECT_UINT

      public static final int FBT_INDIRECT_UINT
      Represent a indirect unsigned integer type
      See Also:
    • FBT_INDIRECT_FLOAT

      public static final int FBT_INDIRECT_FLOAT
      Represent a indirect float type
      See Also:
    • FBT_MAP

      public static final int FBT_MAP
      Represent a map type
      See Also:
    • FBT_VECTOR

      public static final int FBT_VECTOR
      Represent a vector type
      See Also:
    • FBT_VECTOR_INT

      public static final int FBT_VECTOR_INT
      Represent a vector of signed integers type
      See Also:
    • FBT_VECTOR_UINT

      public static final int FBT_VECTOR_UINT
      Represent a vector of unsigned integers type
      See Also:
    • FBT_VECTOR_FLOAT

      public static final int FBT_VECTOR_FLOAT
      Represent a vector of floats type
      See Also:
    • FBT_VECTOR_KEY

      public static final int FBT_VECTOR_KEY
      Represent a vector of keys type
      See Also:
    • FBT_VECTOR_STRING_DEPRECATED

      public static final int FBT_VECTOR_STRING_DEPRECATED
      Represent a vector of strings type
      See Also:
    • FBT_VECTOR_INT2

      public static final int FBT_VECTOR_INT2
      See Also:
    • FBT_VECTOR_UINT2

      public static final int FBT_VECTOR_UINT2
      See Also:
    • FBT_VECTOR_FLOAT2

      public static final int FBT_VECTOR_FLOAT2
      See Also:
    • FBT_VECTOR_INT3

      public static final int FBT_VECTOR_INT3
      See Also:
    • FBT_VECTOR_UINT3

      public static final int FBT_VECTOR_UINT3
      See Also:
    • FBT_VECTOR_FLOAT3

      public static final int FBT_VECTOR_FLOAT3
      See Also:
    • FBT_VECTOR_INT4

      public static final int FBT_VECTOR_INT4
      See Also:
    • FBT_VECTOR_UINT4

      public static final int FBT_VECTOR_UINT4
      See Also:
    • FBT_VECTOR_FLOAT4

      public static final int FBT_VECTOR_FLOAT4
      See Also:
    • FBT_BLOB

      public static final int FBT_BLOB
      Represent a blob type
      See Also:
    • FBT_BOOL

      public static final int FBT_BOOL
      Represent a boolean type
      See Also:
    • FBT_VECTOR_BOOL

      public static final int FBT_VECTOR_BOOL
      Represent a vector of booleans type
      See Also:
    • EMPTY_BB

      private static final ReadBuf EMPTY_BB
  • Constructor Details

    • FlexBuffers

      public FlexBuffers()
  • Method Details

    • isTypedVector

      static boolean isTypedVector(int type)
      Checks where a type is a typed vector
      Parameters:
      type - type to be checked
      Returns:
      true if typed vector
    • isTypeInline

      static boolean isTypeInline(int type)
      Check whether you can access type directly (no indirection) or not.
      Parameters:
      type - type to be checked
      Returns:
      true if inline type
    • toTypedVectorElementType

      static int toTypedVectorElementType(int original_type)
    • toTypedVector

      static int toTypedVector(int type, int fixedLength)
      Return a vector type our of a original element type
      Parameters:
      type - element type
      fixedLength - size of element
      Returns:
      typed vector type
    • isTypedVectorElementType

      static boolean isTypedVectorElementType(int type)
    • indirect

      private static int indirect(ReadBuf bb, int offset, int byteWidth)
    • readUInt

      private static long readUInt(ReadBuf buff, int end, int byteWidth)
    • readInt

      private static int readInt(ReadBuf buff, int end, int byteWidth)
    • readLong

      private static long readLong(ReadBuf buff, int end, int byteWidth)
    • readDouble

      private static double readDouble(ReadBuf buff, int end, int byteWidth)
    • getRoot

      @Deprecated public static FlexBuffers.Reference getRoot(ByteBuffer buffer)
      Deprecated.
      Reads a FlexBuffer message in ReadBuf and returns FlexBuffers.Reference to the root element.
      Parameters:
      buffer - ReadBuf containing FlexBuffer message
      Returns:
      FlexBuffers.Reference to the root object
    • getRoot

      public static FlexBuffers.Reference getRoot(ReadBuf buffer)
      Reads a FlexBuffer message in ReadBuf and returns FlexBuffers.Reference to the root element.
      Parameters:
      buffer - ReadBuf containing FlexBuffer message
      Returns:
      FlexBuffers.Reference to the root object