[Java][FlexBuffers] Abstract buffer access from ByteBuffer (#5743)
authorPaulo Pinheiro <paulovictor.pinheiro@gmail.com>
Fri, 21 Feb 2020 19:46:40 +0000 (20:46 +0100)
committerGitHub <noreply@github.com>
Fri, 21 Feb 2020 19:46:40 +0000 (11:46 -0800)
commitcd88e6b2aa35b7e97f8146be8115a8ff420b1215
treeda788535f9b581354cc55787a580d955e0c4f85c
parent3ec7a53c62520cbf66c81ef8434fb2ba61ded7c0
[Java][FlexBuffers] Abstract buffer access from ByteBuffer (#5743)

To read and build flexbuffers on Java, one needs to wrap the data
using  ByteBuffer. But for the common case of having ByteBuffers
backed by arrays, accessing from a ByteBuffer might be inefficient.

So this change introduces two interfaces: ReadBuf and ReadWriteBuf.
It allows one to read and writes data directly on an array. It also allow
 other buffer implementations to be used with flexbuffers.

Another change is that FlexBuffersBuilder backed by array allows
the buffer to grow with the increase of the message size. Something
that could not be done with ByteBuffer.
java/com/google/flatbuffers/ArrayReadWriteBuf.java [new file with mode: 0644]
java/com/google/flatbuffers/ByteBufferReadWriteBuf.java [new file with mode: 0644]
java/com/google/flatbuffers/FlexBuffers.java
java/com/google/flatbuffers/FlexBuffersBuilder.java
java/com/google/flatbuffers/ReadBuf.java [new file with mode: 0644]
java/com/google/flatbuffers/ReadWriteBuf.java [new file with mode: 0644]
java/com/google/flatbuffers/Utf8Safe.java
tests/JavaTest.java