Class ByteArrayBuffer

java.lang.Object
com.oracle.truffle.regex.tregex.buffer.AbstractArrayBuffer
com.oracle.truffle.regex.tregex.buffer.ByteArrayBuffer
Direct Known Subclasses:
StringBufferASCII, StringBufferLATIN1, StringBufferUTF8

public class ByteArrayBuffer extends AbstractArrayBuffer
This class is designed as a "scratchpad" for generating many byte arrays of unknown size. It will never shrink its internal buffer, so it should be disposed as soon as it is no longer needed.

Usage Example:

 ByteArrayBuffer buf = new ByteArrayBuffer();
 List<byte[]> results = new ArrayList<>();
 for (Object obj : listOfThingsToProcess) {
     for (Object x : obj.thingsThatShouldBecomeBytes()) {
         buf.add(someCalculation(x));
     }
     results.add(buf.toArray());
     buf.clear();
 }
 
  • Constructor Details

    • ByteArrayBuffer

      public ByteArrayBuffer()
    • ByteArrayBuffer

      public ByteArrayBuffer(int initialSize)
  • Method Details

    • get

      public byte get(int i)
    • set

      public void set(int i, byte b)
    • add

      public void add(byte b)
    • toArray

      public byte[] toArray()