Package com.google.flatbuffers
Class FlatBufferBuilder.ByteBufferFactory
- java.lang.Object
-
- com.google.flatbuffers.FlatBufferBuilder.ByteBufferFactory
-
- Direct Known Subclasses:
FlatBufferBuilder.HeapByteBufferFactory
- Enclosing class:
- FlatBufferBuilder
public abstract static class FlatBufferBuilder.ByteBufferFactory extends java.lang.ObjectAn interface that provides a user of the FlatBufferBuilder class the ability to specify the method in which the internal buffer gets allocated. This allows for alternatives to the default behavior, which is to allocate memory for a new byte-array backed `ByteBuffer` array inside the JVM. The FlatBufferBuilder class contains the HeapByteBufferFactory class to preserve the default behavior in the event that the user does not provide their own implementation of this interface.
-
-
Constructor Summary
Constructors Constructor Description ByteBufferFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.nio.ByteBuffernewByteBuffer(int capacity)Create a `ByteBuffer` with a given capacity.voidreleaseByteBuffer(java.nio.ByteBuffer bb)Release a ByteBuffer.
-
-
-
Method Detail
-
newByteBuffer
public abstract java.nio.ByteBuffer newByteBuffer(int capacity)
Create a `ByteBuffer` with a given capacity. The returned ByteBuf must have a ByteOrder.LITTLE_ENDIAN ByteOrder.- Parameters:
capacity- The size of the `ByteBuffer` to allocate.- Returns:
- Returns the new `ByteBuffer` that was allocated.
-
releaseByteBuffer
public void releaseByteBuffer(java.nio.ByteBuffer bb)
Release a ByteBuffer. CurrentFlatBufferBuilderreleased any reference to it, so it is safe to dispose the buffer or return it to a pool. It is not guaranteed that the buffer has been created withnewByteBuffer(int).- Parameters:
bb- the buffer to release
-
-