fm.liveswitch.CircularDataBuffer Class Reference

A DataBuffer that uses a circular buffer to manage data. More...

Public Member Functions

void appendDataBuffer (fm.liveswitch.DataBuffer buffer)
 Appends a data buffer to the correct place in this circular data buffer. More...
 
int beginWrite (int maxWriteSize)
 Tells the CircularDataBuffer to expect more data of up to maxWriteSize. More...
 
void discard (int amount)
 Advances the Index by amount so the space used by the data can be reused. More...
 
void endWrite (int actuallyWrittenSize)
 Tells the CircularDataBuffer how much data was actually written so that the Length can be set appropriately. More...
 
fm.liveswitch.DataBuffer free ()
 Frees the internal pooled DataBuffer. More...
 
int getCapacity ()
 Gets the capacity of this CircularDataBuffer. More...
 
byte[] getData ()
 Gets the data. More...
 
- Public Member Functions inherited from fm.liveswitch.DataBuffer
boolean and (int value, int offset)
 Performs a bitwise "and" operation on a value. More...
 
fm.liveswitch.DataBuffer append (fm.liveswitch.DataBuffer buffer)
 Appends a buffer. More...
 
fm.liveswitch.DataBuffer append (fm.liveswitch.DataBuffer[] buffers)
 Appends some buffers. More...
 
boolean canResize (int newLength, int offset)
 Gets whether this buffer can be resized to the new length. More...
 
fm.liveswitch.DataBuffer clone ()
 Clones this instance. More...
 
fm.liveswitch.DataBuffer clone (boolean littleEndian)
 Clones this instance. More...
 
fm.liveswitch.DataBuffer copy ()
 Copies this instance into new memory. More...
 
fm.liveswitch.DataBuffer copy (boolean usePool)
 Copies this instance. More...
 
int getIndex ()
 Gets the index. More...
 
boolean getIsPooled ()
 Gets whether this DataBuffer is from a pool. More...
 
boolean getIsSubset ()
 Gets whether this DataBuffer is a subset. More...
 
int getLength ()
 Gets the length. More...
 
boolean getLittleEndian ()
 Gets whether fm.liveswitch.DataBuffer#getData is little-endian. More...
 
fm.liveswitch.DataBuffer keep ()
 Increment the retain count by one. More...
 
boolean or (int value, int offset)
 Performs a bitwise "or" operation on a value. More...
 
fm.liveswitch.DataBuffer prepend (fm.liveswitch.DataBuffer buffer)
 Prepends a buffer. More...
 
void prepend (fm.liveswitch.DataBuffer[] buffers)
 Prepends some buffers. More...
 
boolean read1 (int offset, int bitOffset)
 Reads a 1-bit value. More...
 
int read10 (int offset, int bitOffset)
 Reads a 10-bit value. More...
 
int read10Signed (int offset, int bitOffset)
 Reads a 10-bit signed value. More...
 
int read11 (int offset, int bitOffset)
 Reads a 11-bit value. More...
 
int read11Signed (int offset, int bitOffset)
 Reads a 11-bit signed value. More...
 
int read12 (int offset, int bitOffset)
 Reads a 12-bit value. More...
 
int read12Signed (int offset, int bitOffset)
 Reads a 12-bit signed value. More...
 
int read13 (int offset, int bitOffset)
 Reads a 13-bit value. More...
 
int read13Signed (int offset, int bitOffset)
 Reads a 13-bit signed value. More...
 
int read14 (int offset, int bitOffset)
 Reads a 14-bit value. More...
 
int read14Signed (int offset, int bitOffset)
 Reads a 14-bit signed value. More...
 
int read15 (int offset, int bitOffset)
 Reads a 15-bit value. More...
 
int read15Signed (int offset, int bitOffset)
 Reads a 15-bit signed value. More...
 
int read16 (int offset)
 Reads a 16-bit value. More...
 
int read16 (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 16-bit value. More...
 
int read16Signed (int offset)
 Reads a 16-bit signed value. More...
 
int read16Signed (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 16-bit signed value. More...
 
int read17 (int offset, int bitOffset)
 Reads a 17-bit value. More...
 
int read17Signed (int offset, int bitOffset)
 Reads a 17-bit signed value. More...
 
int read18 (int offset, int bitOffset)
 Reads an 18-bit value. More...
 
int read18Signed (int offset, int bitOffset)
 Reads an 18-bit signed value. More...
 
int read19 (int offset, int bitOffset)
 Reads a 19-bit value. More...
 
int read19Signed (int offset, int bitOffset)
 Reads a 19-bit signed value. More...
 
int read2 (int offset, int bitOffset)
 Reads a 2-bit value. More...
 
int read20 (int offset, int bitOffset)
 Reads a 20-bit value. More...
 
int read20Signed (int offset, int bitOffset)
 Reads a 20-bit signed value. More...
 
int read21 (int offset, int bitOffset)
 Reads a 21-bit value. More...
 
int read21Signed (int offset, int bitOffset)
 Reads a 21-bit signed value. More...
 
int read22 (int offset, int bitOffset)
 Reads a 22-bit value. More...
 
int read22Signed (int offset, int bitOffset)
 Reads a 22-bit signed value. More...
 
int read23 (int offset, int bitOffset)
 Reads a 23-bit value. More...
 
int read23Signed (int offset, int bitOffset)
 Reads a 23-bit signed value. More...
 
int read24 (int offset)
 Reads a 24-bit value. More...
 
int read24 (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 24-bit value. More...
 
int read24Signed (int offset)
 Reads a 24-bit signed value. More...
 
int read24Signed (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 24-bit signed value. More...
 
int read2Signed (int offset, int bitOffset)
 Reads a 2-bit signed value. More...
 
int read3 (int offset, int bitOffset)
 Reads a 3-bit value. More...
 
long read32 (int offset)
 Reads a 32-bit value. More...
 
long read32 (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 32-bit value. More...
 
long read32Signed (int offset)
 Reads a 32-bit signed value. More...
 
long read32Signed (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 32-bit signed value. More...
 
int read3Signed (int offset, int bitOffset)
 Reads a 3-bit signed value. More...
 
int read4 (int offset, int bitOffset)
 Reads a 4-bit value. More...
 
long read40 (int offset)
 Reads a 40-bit value. More...
 
long read40 (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 40-bit value. More...
 
long read40Signed (int offset)
 Reads a 40-bit signed value. More...
 
long read40Signed (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 40-bit signed value. More...
 
long read48 (int offset)
 Reads a 48-bit value. More...
 
long read48 (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 48-bit value. More...
 
long read48Signed (int offset)
 Reads a 48-bit signed value. More...
 
long read48Signed (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 48-bit signed value. More...
 
int read4Signed (int offset, int bitOffset)
 Reads a 4-bit signed value. More...
 
int read5 (int offset, int bitOffset)
 Reads a 5-bit value. More...
 
long read56 (int offset)
 Reads a 56-bit value. More...
 
long read56 (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 56-bit value. More...
 
long read56Signed (int offset)
 Reads a 56-bit signed value. More...
 
long read56Signed (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 56-bit signed value. More...
 
int read5Signed (int offset, int bitOffset)
 Reads a 5-bit signed value. More...
 
int read6 (int offset, int bitOffset)
 Reads a 6-bit value. More...
 
long read64 (int offset)
 Reads a 64-bit value. More...
 
long read64 (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 64-bit value. More...
 
long read64Signed (int offset)
 Reads a 64-bit signed value. More...
 
long read64Signed (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads a 64-bit signed value. More...
 
int read6Signed (int offset, int bitOffset)
 Reads a 6-bit signed value. More...
 
int read7 (int offset, int bitOffset)
 Reads a 7-bit value. More...
 
int read7Signed (int offset, int bitOffset)
 Reads a 7-bit signed value. More...
 
int read8 (int offset)
 Reads an 8-bit value. More...
 
int read8 (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads an 8-bit value. More...
 
int read8Signed (int offset)
 Reads an 8-bit signed value. More...
 
int read8Signed (int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Reads an 8-bit signed value. More...
 
int read9 (int offset, int bitOffset)
 Reads a 9-bit value. More...
 
int read9Signed (int offset, int bitOffset)
 Reads a 9-bit signed value. More...
 
String readUtf8String (int offset)
 Read a UTF-8 string. More...
 
String readUtf8String (int offset, int length)
 Reads a UTF-8 string. More...
 
void resize (int newLength)
 Resizes this buffer to a new length with new data being inserted at the end. More...
 
void resize (int newLength, int offset)
 Resizes this buffer to a new length with new data being inserted at a given offset. More...
 
void resize (int newLength, int offset, boolean setZero)
 Resizes this buffer to a new length with new data being inserted at a given offset. More...
 
boolean sequenceEquals (fm.liveswitch.DataBuffer buffer)
 Compares a data buffer for equality. More...
 
boolean sequenceEqualsConstantTime (fm.liveswitch.DataBuffer buffer)
 Compares a data buffer for equality in constant time. More...
 
void set (byte value)
 Sets the data buffer to the specified value. More...
 
void set (byte value, int offset)
 Sets a subset of the data buffer to the specified value. More...
 
void set (byte value, int offset, int length)
 Sets a subset of the data buffer to the specified value. More...
 
void setLittleEndian (boolean value)
 Sets whether fm.liveswitch.DataBuffer#getData is little-endian. More...
 
fm.liveswitch.DataBuffer subset (int offset)
 Gets a subset of this instance. More...
 
fm.liveswitch.DataBuffer subset (int offset, int length)
 Gets a subset of this instance. More...
 
byte[] toArray ()
 Converts this instance to an array of bytes. More...
 
byte[] toBytes ()
 Converts this instance to an array of bytes. More...
 
String toHexString ()
 Converts this instance to a hexadecimal string. More...
 
String toJson ()
 Serializes this instance to JSON. More...
 
boolean tryKeep ()
 Attempts to increment the retain count by one. More...
 
boolean tryRead1 (int offset, int bitOffset, fm.liveswitch.BooleanHolder value)
 Tries to read a 1-bit value. More...
 
boolean tryRead10 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 10-bit value. More...
 
boolean tryRead11 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read an 11-bit value. More...
 
boolean tryRead12 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 12-bit value. More...
 
boolean tryRead13 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 13-bit value. More...
 
boolean tryRead14 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 14-bit value. More...
 
boolean tryRead15 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 15-bit value. More...
 
boolean tryRead16 (int offset, fm.liveswitch.IntegerHolder value)
 Tries to read a 16-bit value. More...
 
boolean tryRead17 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 17-bit value. More...
 
boolean tryRead18 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read an 18-bit value. More...
 
boolean tryRead19 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 19-bit value. More...
 
boolean tryRead2 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 2-bit value. More...
 
boolean tryRead20 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 20-bit value. More...
 
boolean tryRead21 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 21-bit value. More...
 
boolean tryRead22 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 22-bit value. More...
 
boolean tryRead23 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 23-bit value. More...
 
boolean tryRead24 (int offset, fm.liveswitch.IntegerHolder value)
 Tries to read a 24-bit value. More...
 
boolean tryRead3 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 3-bit value. More...
 
boolean tryRead32 (int offset, fm.liveswitch.LongHolder value)
 Tries to read a 32-bit value. More...
 
boolean tryRead4 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 4-bit value. More...
 
boolean tryRead40 (int offset, fm.liveswitch.LongHolder value)
 Tries to read a 40-bit value. More...
 
boolean tryRead48 (int offset, fm.liveswitch.LongHolder value)
 Tries to read a 48-bit value. More...
 
boolean tryRead5 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 5-bit value. More...
 
boolean tryRead56 (int offset, fm.liveswitch.LongHolder value)
 Tries to read a 56-bit value. More...
 
boolean tryRead6 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 6-bit value. More...
 
boolean tryRead64 (int offset, fm.liveswitch.LongHolder value)
 Tries to read a 64-bit value. More...
 
boolean tryRead7 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 7-bit value. More...
 
boolean tryRead8 (int offset, fm.liveswitch.IntegerHolder value)
 Tries to read an 8-bit value. More...
 
boolean tryRead9 (int offset, int bitOffset, fm.liveswitch.IntegerHolder value)
 Tries to read a 9-bit value. More...
 
void write (fm.liveswitch.DataBuffer buffer)
 Writes a data buffer to this instance. More...
 
void write (fm.liveswitch.DataBuffer buffer, int offset)
 Writes a data buffer to this instance. More...
 
void write (fm.liveswitch.DataBuffer buffer, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes a data buffer to this instance. More...
 
boolean write1 (boolean value, int offset, int bitOffset)
 Writes a 1-bit value. More...
 
boolean write10 (int value, int offset, int bitOffset)
 Writes a 10-bit value. More...
 
boolean write11 (int value, int offset, int bitOffset)
 Writes an 11-bit value. More...
 
boolean write12 (int value, int offset, int bitOffset)
 Writes a 12-bit value. More...
 
boolean write13 (int value, int offset, int bitOffset)
 Writes a 13-bit value. More...
 
boolean write14 (int value, int offset, int bitOffset)
 Writes a 14-bit value. More...
 
boolean write15 (int value, int offset, int bitOffset)
 Writes a 15-bit value. More...
 
boolean write16 (int value, int offset)
 Writes a 16-bit value. More...
 
boolean write16 (int value, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes a 16-bit value. More...
 
boolean write16Signed (int value, int offset)
 Writes a signed 16-bit value. More...
 
boolean write17 (int value, int offset, int bitOffset)
 Writes a 17-bit value. More...
 
boolean write18 (int value, int offset, int bitOffset)
 Writes an 18-bit value. More...
 
boolean write19 (int value, int offset, int bitOffset)
 Writes a 19-bit value. More...
 
boolean write2 (int value, int offset, int bitOffset)
 Writes a 2-bit value. More...
 
boolean write20 (int value, int offset, int bitOffset)
 Writes a 20-bit value. More...
 
boolean write21 (int value, int offset, int bitOffset)
 Writes a 21-bit value. More...
 
boolean write22 (int value, int offset, int bitOffset)
 Writes a 22-bit value. More...
 
boolean write23 (int value, int offset, int bitOffset)
 Writes a 23-bit value. More...
 
boolean write24 (int value, int offset)
 Writes a 24-bit value. More...
 
boolean write24 (int value, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes a 24-bit value. More...
 
boolean write3 (int value, int offset, int bitOffset)
 Writes a 3-bit value. More...
 
boolean write32 (long value, int offset)
 Writes a 32-bit value. More...
 
boolean write32 (long value, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes a 32-bit value. More...
 
boolean write4 (int value, int offset, int bitOffset)
 Writes a 4-bit value. More...
 
boolean write40 (long value, int offset)
 Writes a 40-bit value. More...
 
boolean write40 (long value, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes a 40-bit value. More...
 
boolean write48 (long value, int offset)
 Writes a 48-bit value. More...
 
boolean write48 (long value, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes a 48-bit value. More...
 
boolean write5 (int value, int offset, int bitOffset)
 Writes a 5-bit value. More...
 
boolean write56 (long value, int offset)
 Writes a 56-bit value. More...
 
boolean write56 (long value, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes a 56-bit value. More...
 
boolean write6 (int value, int offset, int bitOffset)
 Writes a 6-bit value. More...
 
boolean write64 (long value, int offset)
 Writes a 64-bit value. More...
 
boolean write64 (long value, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes a 64-bit value. More...
 
boolean write7 (int value, int offset, int bitOffset)
 Writes a 7-bit value. More...
 
boolean write8 (int value, int offset)
 Writes an 8-bit value. More...
 
boolean write8 (int value, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes an 8-bit value. More...
 
boolean write9 (int value, int offset, int bitOffset)
 Writes a 9-bit value. More...
 
void writeBytes (byte[] bytes)
 Writes a byte array to this instance. More...
 
void writeBytes (byte[] bytes, int bytesIndex, int bytesLength, int offset)
 Writes a byte array to this instance. More...
 
void writeBytes (byte[] bytes, int bytesIndex, int bytesLength, int offset, fm.liveswitch.IntegerHolder offsetPlus)
 Writes a byte array to this instance. More...
 
void writeBytes (byte[] bytes, int bytesIndex, int offset)
 Writes a byte array to this instance. More...
 
void writeBytes (byte[] bytes, int offset)
 Writes a byte array to this instance. More...
 
boolean xor (int value, int offset)
 Performs a bitwise "xor" operation on a value. More...
 

Static Public Member Functions

static fm.liveswitch.CircularDataBuffer create (int initialSize)
 Creates a new instance of the CircularDataBuffer that can hold a initial amount of data. More...
 
- Static Public Member Functions inherited from fm.liveswitch.DataBuffer
static fm.liveswitch.DataBuffer allocate (int count)
 Allocates a new data buffer with a given size (in bytes) in big-endian format. More...
 
static fm.liveswitch.DataBuffer allocate (int count, boolean littleEndian)
 Allocates a new data buffer with a given size (in bytes). More...
 
static boolean areEqual (fm.liveswitch.DataBuffer buffer1, fm.liveswitch.DataBuffer buffer2)
 Tests if the two buffers have equal contents. More...
 
static fm.liveswitch.DataBuffer fromBytes (byte[] bytes)
 Creates an instance from an array of bytes. More...
 
static fm.liveswitch.DataBuffer fromBytes (byte[] bytes, boolean littleEndian)
 Creates an instance from an array of bytes. More...
 
static fm.liveswitch.DataBuffer fromHexString (String hexString)
 Creates an instance from a hexadecimal string. More...
 
static fm.liveswitch.DataBuffer fromHexString (String hexString, boolean littleEndian)
 Creates an instance from a hexadecimal string. More...
 
static fm.liveswitch.DataBuffer fromJson (String dataBufferJson)
 Deserializes an instance from JSON. More...
 
static fm.liveswitch.DataBuffer[] fromJsonArray (String dataBuffersJson)
 Deserializes an array of instances from JSON. More...
 
static fm.liveswitch.DataBuffer getEmpty ()
 Gets an empty data buffer. More...
 
static String toJson (final fm.liveswitch.DataBuffer dataBuffer)
 Serializes an instance to JSON. More...
 
static String toJsonArray (fm.liveswitch.DataBuffer[] dataBuffers)
 Serializes an array of instances to JSON. More...
 
static fm.liveswitch.DataBuffer wrap (byte[] data)
 Produces a new data buffer containing supplied data in big-endian format. More...
 
static fm.liveswitch.DataBuffer wrap (byte[] data, int index)
 Produces a new data buffer containing supplied data in big-endian format. More...
 
static fm.liveswitch.DataBuffer wrap (byte[] data, int index, int length)
 Produces a new data buffer containing supplied data in big-endian format. More...
 
static fm.liveswitch.DataBuffer wrap (byte[] data, int index, int length, boolean littleEndian)
 Produces a new data buffer containing supplied data. More...
 
static fm.liveswitch.DataBuffer wrap (byte[] data, int index, boolean littleEndian)
 Produces a new data buffer containing supplied data. More...
 
static fm.liveswitch.DataBuffer wrap (byte[] data, boolean littleEndian)
 Produces a new data buffer containing supplied data. More...
 

Additional Inherited Members

- Protected Member Functions inherited from fm.liveswitch.DataBuffer
byte[] getInnerData ()
 Gets backing data buffer. More...
 
void setIndex (int value)
 Sets the index. More...
 
void setInnerData (byte[] value)
 Sets backing data buffer. More...
 
void setLength (int value)
 Sets the length. More...
 

Detailed Description

A DataBuffer that uses a circular buffer to manage data.

Member Function Documentation

◆ appendDataBuffer()

void fm.liveswitch.CircularDataBuffer.appendDataBuffer ( fm.liveswitch.DataBuffer  buffer)

Appends a data buffer to the correct place in this circular data buffer.

Parameters
bufferThe buffer to write.

◆ beginWrite()

int fm.liveswitch.CircularDataBuffer.beginWrite ( int  maxWriteSize)

Tells the CircularDataBuffer to expect more data of up to maxWriteSize.

Will reshuffle data around or resize if necessary.

Parameters
maxWriteSizeThe amount of bytes to make available for writing.

◆ create()

static fm.liveswitch.CircularDataBuffer fm.liveswitch.CircularDataBuffer.create ( int  initialSize)
static

Creates a new instance of the CircularDataBuffer that can hold a initial amount of data.

Parameters
initialSizeThe initial size of the inner buffer.

◆ discard()

void fm.liveswitch.CircularDataBuffer.discard ( int  amount)

Advances the Index by amount so the space used by the data can be reused.

Parameters
amountThe amount to advance the Index by.

◆ endWrite()

void fm.liveswitch.CircularDataBuffer.endWrite ( int  actuallyWrittenSize)

Tells the CircularDataBuffer how much data was actually written so that the Length can be set appropriately.

Parameters
actuallyWrittenSizeThe amount of data actually written to the data buffer.

◆ free()

fm.liveswitch.DataBuffer fm.liveswitch.CircularDataBuffer.free ( )

Frees the internal pooled DataBuffer.

Reimplemented from fm.liveswitch.DataBuffer.

◆ getCapacity()

int fm.liveswitch.CircularDataBuffer.getCapacity ( )

Gets the capacity of this CircularDataBuffer.

◆ getData()

byte [] fm.liveswitch.CircularDataBuffer.getData ( )

Gets the data.

Reimplemented from fm.liveswitch.DataBuffer.