Class ByteStringBuilder

java.lang.Object
org.apache.pekko.util.ByteStringBuilder
All Implemented Interfaces:
scala.collection.mutable.Builder<Object,ByteString>, scala.collection.mutable.Clearable, scala.collection.mutable.Growable<Object>

public final class ByteStringBuilder extends Object implements scala.collection.mutable.Builder<Object,ByteString>
A mutable builder for efficiently creating a ByteString.

The created ByteString is not automatically compacted.

  • Constructor Details

    • ByteStringBuilder

      public ByteStringBuilder()
  • Method Details

    • $plus$plus$eq

      public ByteStringBuilder $plus$plus$eq(ByteString bytes)
    • addAll

      public ByteStringBuilder addAll(ByteString bytes)
    • addAll

      public ByteStringBuilder addAll(scala.collection.IterableOnce<Object> xs)
      Specified by:
      addAll in interface scala.collection.mutable.Growable<Object>
    • addOne

      public ByteStringBuilder addOne(byte elem)
    • append

      public ByteStringBuilder append(ByteString bs)
      Java API: append a ByteString to this builder.
    • asOutputStream

      public OutputStream asOutputStream()
      Directly wraps this ByteStringBuilder in an OutputStream. Write operations on the stream are forwarded to the builder.
    • clear

      public void clear()
      Specified by:
      clear in interface scala.collection.mutable.Builder<Object,ByteString>
      Specified by:
      clear in interface scala.collection.mutable.Clearable
    • fillArray

      protected ByteStringBuilder fillArray(int len, scala.Function2<byte[],Object,scala.runtime.BoxedUnit> fill)
    • fillByteBuffer

      protected final ByteStringBuilder fillByteBuffer(int len, ByteOrder byteOrder, scala.Function1<ByteBuffer,scala.runtime.BoxedUnit> fill)
    • isEmpty

      public boolean isEmpty()
      Tests whether this ByteStringBuilder is empty.
    • length

      public int length()
    • nonEmpty

      public boolean nonEmpty()
      Tests whether this ByteStringBuilder is not empty.
    • putByte

      public ByteStringBuilder putByte(byte x)
      Add a single Byte to this builder.
    • putBytes

      public ByteStringBuilder putBytes(byte[] array)
      Add a number of Bytes from an array to this builder.
    • putBytes

      public ByteStringBuilder putBytes(byte[] array, int start, int len)
      Add a number of Bytes from an array to this builder.
    • putDouble

      public ByteStringBuilder putDouble(double x, ByteOrder byteOrder)
      Add a single Double to this builder.
    • putDoubles

      public ByteStringBuilder putDoubles(double[] array, ByteOrder byteOrder)
      Add a number of Doubles from an array to this builder.
    • putDoubles

      public ByteStringBuilder putDoubles(double[] array, int start, int len, ByteOrder byteOrder)
      Add a number of Doubles from an array to this builder.
    • putFloat

      public ByteStringBuilder putFloat(float x, ByteOrder byteOrder)
      Add a single Float to this builder.
    • putFloats

      public ByteStringBuilder putFloats(float[] array, ByteOrder byteOrder)
      Add a number of Floats from an array to this builder.
    • putFloats

      public ByteStringBuilder putFloats(float[] array, int start, int len, ByteOrder byteOrder)
      Add a number of Floats from an array to this builder.
    • putInt

      public ByteStringBuilder putInt(int x, ByteOrder byteOrder)
      Add a single Int to this builder.
    • putInts

      public ByteStringBuilder putInts(int[] array, ByteOrder byteOrder)
      Add a number of Ints from an array to this builder.
    • putInts

      public ByteStringBuilder putInts(int[] array, int start, int len, ByteOrder byteOrder)
      Add a number of Ints from an array to this builder.
    • putLong

      public ByteStringBuilder putLong(long x, ByteOrder byteOrder)
      Add a single Long to this builder.
    • putLongPart

      public ByteStringBuilder putLongPart(long x, int n, ByteOrder byteOrder)
      Add the n least significant bytes of the given Long to this builder.
    • putLongs

      public ByteStringBuilder putLongs(long[] array, ByteOrder byteOrder)
      Add a number of Longs from an array to this builder.
    • putLongs

      public ByteStringBuilder putLongs(long[] array, int start, int len, ByteOrder byteOrder)
      Add a number of Longs from an array to this builder.
    • putShort

      public ByteStringBuilder putShort(int x, ByteOrder byteOrder)
      Add a single Short to this builder.
    • putShorts

      public ByteStringBuilder putShorts(short[] array, ByteOrder byteOrder)
      Add a number of Shorts from an array to this builder.
    • putShorts

      public ByteStringBuilder putShorts(short[] array, int start, int len, ByteOrder byteOrder)
      Add a number of Shorts from an array to this builder.
    • result

      public ByteString result()
      Specified by:
      result in interface scala.collection.mutable.Builder<Object,ByteString>
    • sizeHint

      public void sizeHint(int len)
      Specified by:
      sizeHint in interface scala.collection.mutable.Builder<Object,ByteString>