Class ByteString$

java.lang.Object
org.apache.pekko.util.ByteString$

public class ByteString$ extends Object
  • Field Details

    • MODULE$

      public static final ByteString$ MODULE$
      Static reference to the singleton instance of this Scala object.
  • Constructor Details

    • ByteString$

      public ByteString$()
  • Method Details

    • fromInts

      public ByteString fromInts(int... array)
      JAVA API Creates a new ByteString by copying an int array by converting from integral numbers to bytes.
    • apply

      public ByteString apply(byte[] bytes)
      Creates a new ByteString by copying a byte array.
    • apply

      public ByteString apply(scala.collection.immutable.Seq<Object> bytes)
      Creates a new ByteString by copying bytes.
    • apply

      public ByteString apply(scala.collection.IterableOnce<Object> bytes)
      Creates a new ByteString by iterating over bytes.
    • apply

      public <T> ByteString apply(scala.collection.immutable.Seq<T> bytes, scala.math.Integral<T> num)
      Creates a new ByteString by converting from integral numbers to bytes.
    • apply

      public ByteString apply(ByteBuffer bytes)
      Creates a new ByteString by copying bytes from a ByteBuffer.
    • apply

      public ByteString apply(String string)
      Creates a new ByteString by encoding a String as UTF-8.
    • apply

      public ByteString apply(String string, String charset)
      Creates a new ByteString by encoding a String with a charset.
    • apply

      public ByteString apply(String string, Charset charset)
      Creates a new ByteString by encoding a String with a charset.
    • fromArray

      public ByteString fromArray(byte[] array)
      Creates a new ByteString by copying a byte array.
    • fromArrayUnsafe

      public ByteString fromArrayUnsafe(byte[] array)
      Unsafe API: Use only in situations you are completely confident that this is what you need, and that you understand the implications documented below.

      Creates a ByteString without copying the passed in byte array, unlike other factory methods defined on ByteString. This method of creating a ByteString saves one array copy and allocation and therefore can lead to better performance, however it also means that one MUST NOT modify the passed in array, or unexpected immutable data structure contract-breaking behavior will manifest itself.

      This API is intended for users who have obtained an byte array from some other API, and want wrap it into an ByteArray, and from there on only use that reference (the ByteString) to operate on the wrapped data. For all other intents and purposes, please use the usual apply and create methods - which provide the immutability guarantees by copying the array.

    • fromArray

      public ByteString fromArray(byte[] array, int offset, int length)
      Creates a new ByteString by copying length bytes starting at offset from an Array.
    • fromArrayUnsafe

      public ByteString fromArrayUnsafe(byte[] array, int offset, int length)
      Unsafe API: Use only in situations you are completely confident that this is what you need, and that you understand the implications documented below.

      Creates a ByteString without copying the passed in byte array, unlike other factory methods defined on ByteString. This method of creating a ByteString saves one array copy and allocation and therefore can lead to better performance, however it also means that one MUST NOT modify the passed in array, or unexpected immutable data structure contract-breaking behavior will manifest itself.

      This API is intended for users who have obtained an byte array from some other API, and want wrap it into an ByteArray, and from there on only use that reference (the ByteString) to operate on the wrapped data. For all other intents and purposes, please use the usual apply and create methods - which provide the immutability guarantees by copying the array.

    • fromInts

      public ByteString fromInts(scala.collection.immutable.Seq<Object> array)
      JAVA API Creates a new ByteString by copying an int array by converting from integral numbers to bytes.
    • fromString

      public ByteString fromString(String string)
      Creates a new ByteString which will contain the UTF-8 representation of the given String
    • fromString

      public ByteString fromString(String string, String charset)
      Creates a new ByteString which will contain the representation of the given String in the given charset
    • fromString

      public ByteString fromString(String string, Charset charset)
      Creates a new ByteString which will contain the representation of the given String in the given charset
    • UTF_8

      public String UTF_8()
      Standard "UTF-8" charset
    • fromByteBuffer

      public ByteString fromByteBuffer(ByteBuffer buffer)
      Creates a new ByteString by copying bytes out of a ByteBuffer.
    • empty

      public ByteString empty()
    • emptyByteString

      public ByteString emptyByteString()
      Java API
    • newBuilder

      public ByteStringBuilder newBuilder()
    • createBuilder

      public ByteStringBuilder createBuilder()
      Java API