public class ArrayReadWriteBuf extends Object implements ReadWriteBuf
com.google.flatbuffers.ReadBuf using an array of bytes as a backing storage. Using array of bytes are
usually faster than ByteBuffer.
This class is not thread-safe, meaning that it must operate on a single thread. Operating from multiple thread leads into an undefined behavior
| Constructor and Description |
|---|
ArrayReadWriteBuf() |
ArrayReadWriteBuf(byte[] buffer) |
ArrayReadWriteBuf(byte[] buffer,
int startPos) |
ArrayReadWriteBuf(int initialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears (resets) the buffer so that it can be reused.
|
byte[] |
data()
Expose com.google.flatbuffers.ReadBuf as an array of bytes.
|
byte |
get(int index)
Read a byte from data.
|
boolean |
getBoolean(int index)
Read boolean from data.
|
double |
getDouble(int index)
Read a 64-bit float from data.
|
float |
getFloat(int index)
Read a 32-bit float from data.
|
int |
getInt(int index)
Read a 32-bit int from data.
|
long |
getLong(int index)
Read a 64-bit long from data.
|
short |
getShort(int index)
Read a short from data.
|
String |
getString(int start,
int size)
Read an UTF-8 string from data.
|
int |
limit()
Defines the size of the message in the buffer.
|
void |
put(byte value)
Write a byte into the buffer at
writePosition(). |
void |
put(byte[] value,
int start,
int length)
Put an array of bytes into the buffer at
writePosition(). |
void |
putBoolean(boolean value)
Put a boolean into the buffer at
writePosition() . |
void |
putDouble(double value)
Write a 64-bit float into the buffer at
writePosition(). |
void |
putFloat(float value)
Write a 32-bit float into the buffer at
writePosition(). |
void |
putInt(int value)
Write a 32-bit into in the buffer at
writePosition(). |
void |
putLong(long value)
Write a 64-bit into in the buffer at
writePosition(). |
void |
putShort(short value)
Write a 16-bit into in the buffer at
writePosition(). |
boolean |
requestCapacity(int capacity)
Request capacity of the buffer.
|
void |
set(int index,
byte value)
Read a byte from data.
|
void |
set(int index,
byte[] toCopy,
int start,
int length)
Write an array of bytes into the buffer.
|
void |
setBoolean(int index,
boolean value)
Write boolean into a given position on the buffer.
|
void |
setDouble(int index,
double value)
Read a 64-bit float from data.
|
void |
setFloat(int index,
float value)
Read a 32-bit float from data.
|
void |
setInt(int index,
int value)
Read a 32-bit int from data.
|
void |
setLong(int index,
long value)
Read a 64-bit long from data.
|
void |
setShort(int index,
short value)
Read a short from data.
|
int |
writePosition() |
public ArrayReadWriteBuf()
public ArrayReadWriteBuf(byte[] buffer)
public ArrayReadWriteBuf(byte[] buffer,
int startPos)
public ArrayReadWriteBuf(int initialCapacity)
public void clear()
ReadWriteBufclear in interface ReadWriteBufpublic byte[] data()
ReadBufpublic byte get(int index)
ReadBufpublic boolean getBoolean(int index)
ReadBufgetBoolean in interface ReadBufindex - position of the element in com.google.flatbuffers.ReadBufpublic double getDouble(int index)
ReadBufpublic float getFloat(int index)
ReadBufpublic int getInt(int index)
ReadBufpublic long getLong(int index)
ReadBufpublic short getShort(int index)
ReadBufpublic String getString(int start, int size)
ReadBufpublic int limit()
ReadWriteBuflimit() -1.limit in interface ReadBuflimit in interface ReadWriteBufpublic void put(byte value)
ReadWriteBufwritePosition(). Write position will be incremented.put in interface ReadWriteBufpublic void put(byte[] value,
int start,
int length)
ReadWriteBufwritePosition(). Write position will be
incremented.put in interface ReadWriteBufvalue - the data to be copiedstart - initial position on value to be copiedlength - amount of bytes to be copiedpublic void putBoolean(boolean value)
ReadWriteBufwritePosition() . Booleans as stored as single byte.
Write position will be incremented.putBoolean in interface ReadWriteBufpublic void putDouble(double value)
ReadWriteBufwritePosition(). Write position will be
incremented.putDouble in interface ReadWriteBufpublic void putFloat(float value)
ReadWriteBufwritePosition(). Write position will be
incremented.putFloat in interface ReadWriteBufpublic void putInt(int value)
ReadWriteBufwritePosition(). Write position will be
incremented.putInt in interface ReadWriteBufpublic void putLong(long value)
ReadWriteBufwritePosition(). Write position will be
incremented.putLong in interface ReadWriteBufpublic void putShort(short value)
ReadWriteBufwritePosition(). Write position will be
incremented.putShort in interface ReadWriteBufpublic boolean requestCapacity(int capacity)
ReadWriteBufrequestCapacity in interface ReadWriteBufpublic void set(int index,
byte value)
ReadWriteBufset in interface ReadWriteBufindex - position of the element in the bufferpublic void set(int index,
byte[] toCopy,
int start,
int length)
ReadWriteBufset in interface ReadWriteBufindex - initial position of the buffer to be writtentoCopy - the data to be copiedstart - initial position on value to be copiedlength - amount of bytes to be copiedpublic void setBoolean(int index,
boolean value)
ReadWriteBufsetBoolean in interface ReadWriteBufindex - position of the element in bufferpublic void setDouble(int index,
double value)
ReadWriteBufsetDouble in interface ReadWriteBufindex - position of the element in com.google.flatbuffers.ReadBufpublic void setFloat(int index,
float value)
ReadWriteBufsetFloat in interface ReadWriteBufindex - position of the element in com.google.flatbuffers.ReadBufpublic void setInt(int index,
int value)
ReadWriteBufsetInt in interface ReadWriteBufindex - position of the element in com.google.flatbuffers.ReadBufpublic void setLong(int index,
long value)
ReadWriteBufsetLong in interface ReadWriteBufindex - position of the element in com.google.flatbuffers.ReadBufpublic void setShort(int index,
short value)
ReadWriteBufsetShort in interface ReadWriteBufindex - position of the element in com.google.flatbuffers.ReadBufpublic int writePosition()
writePosition in interface ReadWriteBuf