FlatBuffers
An open source project by FPL.
com.google.flatbuffers.ArrayReadWriteBuf Class Reference

Implements. More...

Inheritance diagram for com.google.flatbuffers.ArrayReadWriteBuf:
com.google.flatbuffers.ReadWriteBuf com.google.flatbuffers.ReadBuf

Detailed Description

Implements.

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 a undefined behavior

Public Member Functions

 ArrayReadWriteBuf (byte[] buffer)
 
 ArrayReadWriteBuf (byte[] buffer, int startPos)
 
 ArrayReadWriteBuf (int initialCapacity)
 
void clear ()
 Clears (resets) the buffer so that it can be reused. More...
 
byte[] data ()
 Expose ReadBuf as an array of bytes. More...
 
byte get (int index)
 Read a byte from data. More...
 
boolean getBoolean (int index)
 Read boolean from data. More...
 
double getDouble (int index)
 Read a 64-bit float from data. More...
 
float getFloat (int index)
 Read a 32-bit float from data. More...
 
int getInt (int index)
 Read a 32-bit int from data. More...
 
long getLong (int index)
 Read a 64-bit long from data. More...
 
short getShort (int index)
 Read a short from data. More...
 
String getString (int start, int size)
 Read an UTF-8 string from data. More...
 
int limit ()
 Defines the size of the message in the buffer. More...
 
void put (byte value)
 Write a byte into the buffer at. More...
 
void put (byte[] value, int start, int length)
 Put an array of bytes into the buffer at. More...
 
void putBoolean (boolean value)
 Put a boolean into the buffer at. More...
 
void putDouble (double value)
 Write a 64-bit float into the buffer at. More...
 
void putFloat (float value)
 Write a 32-bit float into the buffer at. More...
 
void putInt (int value)
 Write a 32-bit into in the buffer at. More...
 
void putLong (long value)
 Write a 64-bit into in the buffer at. More...
 
void putShort (short value)
 Write a 16-bit into in the buffer at. More...
 
boolean requestCapacity (int capacity)
 Request capacity of the buffer. More...
 
void set (int index, byte value)
 Read a byte from data. More...
 
void set (int index, byte[] toCopy, int start, int length)
 Write an array of bytes into the buffer. More...
 
void setBoolean (int index, boolean value)
 Write boolean into a given position on the buffer. More...
 
void setDouble (int index, double value)
 Read a 64-bit float from data. More...
 
void setFloat (int index, float value)
 Read a 32-bit float from data. More...
 
void setInt (int index, int value)
 Read a 32-bit int from data. More...
 
void setLong (int index, long value)
 Read a 64-bit long from data. More...
 
void setShort (int index, short value)
 Read a short from data. More...
 
int writePosition ()
 

Member Function Documentation

◆ clear()

void com.google.flatbuffers.ArrayReadWriteBuf.clear ( )
inline

Clears (resets) the buffer so that it can be reused.

Write position will be set to the start.

Implements com.google.flatbuffers.ReadWriteBuf.

◆ data()

byte [] com.google.flatbuffers.ArrayReadWriteBuf.data ( )
inline

Expose ReadBuf as an array of bytes.

This method is meant to be as efficient as possible, so for a array-backed ReadBuf, it should return its own internal data. In case access to internal data is not possible, a copy of the data into an array of bytes might occur.

Returns
ReadBuf as an array of bytes

Implements com.google.flatbuffers.ReadBuf.

◆ get()

byte com.google.flatbuffers.ArrayReadWriteBuf.get ( int  index)
inline

Read a byte from data.

Parameters
indexposition of the element in ReadBuf
Returns
a byte

Implements com.google.flatbuffers.ReadBuf.

◆ getBoolean()

boolean com.google.flatbuffers.ArrayReadWriteBuf.getBoolean ( int  index)
inline

Read boolean from data.

Booleans as stored as single byte

Parameters
indexposition of the element in ReadBuf
Returns
boolean element

Implements com.google.flatbuffers.ReadBuf.

◆ getDouble()

double com.google.flatbuffers.ArrayReadWriteBuf.getDouble ( int  index)
inline

Read a 64-bit float from data.

Parameters
indexposition of the element in ReadBuf
Returns
a double

Implements com.google.flatbuffers.ReadBuf.

◆ getFloat()

float com.google.flatbuffers.ArrayReadWriteBuf.getFloat ( int  index)
inline

Read a 32-bit float from data.

Parameters
indexposition of the element in ReadBuf
Returns
a float

Implements com.google.flatbuffers.ReadBuf.

◆ getInt()

int com.google.flatbuffers.ArrayReadWriteBuf.getInt ( int  index)
inline

Read a 32-bit int from data.

Parameters
indexposition of the element in ReadBuf
Returns
an int

Implements com.google.flatbuffers.ReadBuf.

◆ getLong()

long com.google.flatbuffers.ArrayReadWriteBuf.getLong ( int  index)
inline

Read a 64-bit long from data.

Parameters
indexposition of the element in ReadBuf
Returns
a long

Implements com.google.flatbuffers.ReadBuf.

◆ getShort()

short com.google.flatbuffers.ArrayReadWriteBuf.getShort ( int  index)
inline

Read a short from data.

Parameters
indexposition of the element in ReadBuf
Returns
a short

Implements com.google.flatbuffers.ReadBuf.

◆ getString()

String com.google.flatbuffers.ArrayReadWriteBuf.getString ( int  start,
int  size 
)
inline

Read an UTF-8 string from data.

Parameters
startinitial element of the string
sizesize of the string in bytes.
Returns
a
String

Implements com.google.flatbuffers.ReadBuf.

◆ limit()

int com.google.flatbuffers.ArrayReadWriteBuf.limit ( )
inline

Defines the size of the message in the buffer.

It also determines last position that buffer can be read or write. Last byte to be accessed is in position

limit() -1
int limit()
Defines the size of the message in the buffer.
Definition: ArrayReadWriteBuf.java:226

.

Returns
indicate last position

Implements com.google.flatbuffers.ReadWriteBuf.

◆ put() [1/2]

void com.google.flatbuffers.ArrayReadWriteBuf.put ( byte  value)
inline

Write a byte into the buffer at.

writePosition()

. Write position will be incremented.

Implements com.google.flatbuffers.ReadWriteBuf.

◆ put() [2/2]

void com.google.flatbuffers.ArrayReadWriteBuf.put ( byte[]  value,
int  start,
int  length 
)
inline

Put an array of bytes into the buffer at.

writePosition()

. Write position will be incremented.

Parameters
valuethe data to be copied
startinitial position on value to be copied
lengthamount of bytes to be copied

Implements com.google.flatbuffers.ReadWriteBuf.

◆ putBoolean()

void com.google.flatbuffers.ArrayReadWriteBuf.putBoolean ( boolean  value)
inline

Put a boolean into the buffer at.

writePosition()

. Booleans as stored as single byte. Write position will be incremented.

Returns
boolean element

Implements com.google.flatbuffers.ReadWriteBuf.

◆ putDouble()

void com.google.flatbuffers.ArrayReadWriteBuf.putDouble ( double  value)
inline

Write a 64-bit float into the buffer at.

writePosition()

. Write position will be incremented.

Implements com.google.flatbuffers.ReadWriteBuf.

◆ putFloat()

void com.google.flatbuffers.ArrayReadWriteBuf.putFloat ( float  value)
inline

Write a 32-bit float into the buffer at.

writePosition()

. Write position will be incremented.

Implements com.google.flatbuffers.ReadWriteBuf.

◆ putInt()

void com.google.flatbuffers.ArrayReadWriteBuf.putInt ( int  value)
inline

Write a 32-bit into in the buffer at.

writePosition()

. Write position will be incremented.

Implements com.google.flatbuffers.ReadWriteBuf.

◆ putLong()

void com.google.flatbuffers.ArrayReadWriteBuf.putLong ( long  value)
inline

Write a 64-bit into in the buffer at.

writePosition()

. Write position will be incremented.

Implements com.google.flatbuffers.ReadWriteBuf.

◆ putShort()

void com.google.flatbuffers.ArrayReadWriteBuf.putShort ( short  value)
inline

Write a 16-bit into in the buffer at.

writePosition()

. Write position will be incremented.

Implements com.google.flatbuffers.ReadWriteBuf.

◆ requestCapacity()

boolean com.google.flatbuffers.ArrayReadWriteBuf.requestCapacity ( int  capacity)
inline

Request capacity of the buffer.

In case buffer is already larger than the requested, this method will just return true. Otherwise It might try to resize the buffer.

Returns
true if buffer is able to offer the requested capacity

Implements com.google.flatbuffers.ReadWriteBuf.

◆ set() [1/2]

void com.google.flatbuffers.ArrayReadWriteBuf.set ( int  index,
byte  value 
)
inline

Read a byte from data.

Parameters
indexposition of the element in the buffer
Returns
a byte

Implements com.google.flatbuffers.ReadWriteBuf.

◆ set() [2/2]

void com.google.flatbuffers.ArrayReadWriteBuf.set ( int  index,
byte[]  value,
int  start,
int  length 
)
inline

Write an array of bytes into the buffer.

Parameters
indexinitial position of the buffer to be written
valuethe data to be copied
startinitial position on value to be copied
lengthamount of bytes to be copied

Implements com.google.flatbuffers.ReadWriteBuf.

◆ setBoolean()

void com.google.flatbuffers.ArrayReadWriteBuf.setBoolean ( int  index,
boolean  value 
)
inline

Write boolean into a given position on the buffer.

Booleans as stored as single byte.

Parameters
indexposition of the element in buffer

Implements com.google.flatbuffers.ReadWriteBuf.

◆ setDouble()

void com.google.flatbuffers.ArrayReadWriteBuf.setDouble ( int  index,
double  value 
)
inline

Read a 64-bit float from data.

Parameters
indexposition of the element in ReadBuf
Returns
a double

Implements com.google.flatbuffers.ReadWriteBuf.

◆ setFloat()

void com.google.flatbuffers.ArrayReadWriteBuf.setFloat ( int  index,
float  value 
)
inline

Read a 32-bit float from data.

Parameters
indexposition of the element in ReadBuf
Returns
a float

Implements com.google.flatbuffers.ReadWriteBuf.

◆ setInt()

void com.google.flatbuffers.ArrayReadWriteBuf.setInt ( int  index,
int  value 
)
inline

Read a 32-bit int from data.

Parameters
indexposition of the element in ReadBuf
Returns
an int

Implements com.google.flatbuffers.ReadWriteBuf.

◆ setLong()

void com.google.flatbuffers.ArrayReadWriteBuf.setLong ( int  index,
long  value 
)
inline

Read a 64-bit long from data.

Parameters
indexposition of the element in ReadBuf
Returns
a long

Implements com.google.flatbuffers.ReadWriteBuf.

◆ setShort()

void com.google.flatbuffers.ArrayReadWriteBuf.setShort ( int  index,
short  value 
)
inline

Read a short from data.

Parameters
indexposition of the element in ReadBuf
Returns
a short

Implements com.google.flatbuffers.ReadWriteBuf.


The documentation for this class was generated from the following file: