Class ByteArrayBuilder

java.lang.Object
com.github.gbenroscience.util.io.ByteArrayBuilder
All Implemented Interfaces:
Cloneable

public final class ByteArrayBuilder extends Object implements Cloneable
High-performance, thread-safe byte array builder with runtime endianness toggle.
Author:
GBEMIRO
  • Constructor Details

    • ByteArrayBuilder

      public ByteArrayBuilder()
    • ByteArrayBuilder

      public ByteArrayBuilder(boolean littleEndian)
    • ByteArrayBuilder

      public ByteArrayBuilder(byte[] array)
    • ByteArrayBuilder

      public ByteArrayBuilder(byte[] array, boolean littleEndian)
    • ByteArrayBuilder

      public ByteArrayBuilder(ByteBuffer buffer)
    • ByteArrayBuilder

      public ByteArrayBuilder(ByteBuffer buffer, boolean littleEndian)
  • Method Details

    • getByteOrder

      public ByteOrder getByteOrder()
    • append

      public ByteArrayBuilder append(long number)
    • append

      public ByteArrayBuilder append(double number)
    • append

      public ByteArrayBuilder append(int number)
    • append

      public ByteArrayBuilder append(short number)
    • append

      public ByteArrayBuilder append(byte data)
    • append

      public ByteArrayBuilder append(byte[] data)
    • append

      public ByteArrayBuilder append(short[] data)
      Appends a short array to this builder (respects current endianness).
    • append

      public ByteArrayBuilder append(int[] data)
      Appends an int array to this builder (respects current endianness).
    • append

      public ByteArrayBuilder append(float[] data)
      Appends a float array to this builder (respects current endianness).
    • append

      public ByteArrayBuilder append(char[] data)
      Appends a char array to this builder (respects current endianness). Each char is stored as 2 bytes.
    • append

      public ByteArrayBuilder append(boolean[] data)
      Appends a boolean array to this builder. Each boolean is stored as 1 byte (0 = false, 1 = true).
    • append

      public ByteArrayBuilder append(long[] data)
      Appends a long array to this builder (respects current endianness).
    • append

      public ByteArrayBuilder append(double[] data)
    • append

      public ByteArrayBuilder append(byte[] data, boolean last)
    • append

      public ByteArrayBuilder append(ByteBuffer buf)
    • appendItems

      public ByteArrayBuilder appendItems(byte[] data, int offset, int numOfItems, boolean last)
    • appendItems

      public ByteArrayBuilder appendItems(byte[] data, int offset, int numOfItems)
    • append

      public ByteArrayBuilder append(byte[] data, int fromIndex, int toIndex)
    • append

      public ByteArrayBuilder append(byte[] data, int fromIndex, int toIndex, boolean last)
      Appends bytes from fromIndex to toIndex **inclusive** (original API behaviour).
      Parameters:
      data -
      fromIndex -
      toIndex -
      last -
      Returns:
    • prepend

      public ByteArrayBuilder prepend(byte[] data)
    • insert

      public ByteArrayBuilder insert(int index, byte[] data)
    • get

      public byte get(int index)
    • set

      public void set(int index, byte number)
    • set

      public ByteArrayBuilder set(int startIndex, byte[] data)
    • get

      public byte[] get(int startIndex, int numberOfItems)
    • remove

      public ByteArrayBuilder remove(int start, int numberOfItems)
    • getBytes

      public byte[] getBytes()
    • getAsDoubleArray

      public double[] getAsDoubleArray()
    • length

      public int length()
    • commitedLength

      public int commitedLength()
    • nonCommitedLength

      public int nonCommitedLength()
    • clone

      public ByteArrayBuilder clone()
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • log

      public void log()
    • sync

      public void sync()
    • clear

      public void clear()