Package akka.util

Class ByteString$


  • public class ByteString$
    extends java.lang.Object
    Creates a new ByteString by copying a byte array.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ByteString$ MODULE$
      Static reference to the singleton instance of this Scala object.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteString$()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ByteString apply​(byte[] bytes)  
      ByteString apply​(java.lang.String string)
      Creates a new ByteString by encoding a String as UTF-8.
      ByteString apply​(java.lang.String string, java.lang.String charset)
      Creates a new ByteString by encoding a String with a charset.
      ByteString apply​(java.lang.String string, java.nio.charset.Charset charset)
      Creates a new ByteString by encoding a String with a charset.
      ByteString apply​(java.nio.ByteBuffer bytes)
      Creates a new ByteString by copying bytes from a ByteBuffer.
      ByteString apply​(scala.collection.Seq<java.lang.Object> bytes)
      Creates a new ByteString by copying bytes.
      <T> ByteString apply​(scala.collection.Seq<T> bytes, scala.math.Integral<T> num)
      Creates a new ByteString by converting from integral numbers to bytes.
      scala.collection.generic.CanBuildFrom<scala.collection.TraversableOnce<java.lang.Object>,​java.lang.Object,​ByteString> canBuildFrom()  
      ByteStringBuilder createBuilder()
      Java API
      ByteString empty()  
      ByteString emptyByteString()
      Java API
      ByteString fromArray​(byte[] array)
      Creates a new ByteString by copying a byte array.
      ByteString fromArray​(byte[] array, int offset, int length)
      Creates a new ByteString by copying length bytes starting at offset from an Array.
      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.
      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.
      ByteString fromByteBuffer​(java.nio.ByteBuffer buffer)
      Creates a new ByteString by copying bytes out of a ByteBuffer.
      ByteString fromInts​(int... array)  
      ByteString fromInts​(scala.collection.Seq<java.lang.Object> array)
      JAVA API Creates a new ByteString by copying an int array by converting from integral numbers to bytes.
      ByteString fromString​(java.lang.String string)
      Creates a new ByteString which will contain the UTF-8 representation of the given String
      ByteString fromString​(java.lang.String string, java.lang.String charset)
      Creates a new ByteString which will contain the representation of the given String in the given charset
      ByteString fromString​(java.lang.String string, java.nio.charset.Charset charset)
      Creates a new ByteString which will contain the representation of the given String in the given charset
      ByteStringBuilder newBuilder()  
      java.lang.String UTF_8()
      Standard "UTF-8" charset
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MODULE$

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

      • ByteString$

        public ByteString$()
    • Method Detail

      • fromInts

        public ByteString fromInts​(int... array)
      • apply

        public ByteString apply​(byte[] bytes)
      • apply

        public ByteString apply​(scala.collection.Seq<java.lang.Object> bytes)
        Creates a new ByteString by copying bytes.
        Parameters:
        bytes - (undocumented)
        Returns:
        (undocumented)
      • apply

        public <T> ByteString apply​(scala.collection.Seq<T> bytes,
                                    scala.math.Integral<T> num)
        Creates a new ByteString by converting from integral numbers to bytes.
        Parameters:
        bytes - (undocumented)
        num - (undocumented)
        Returns:
        (undocumented)
      • apply

        public ByteString apply​(java.nio.ByteBuffer bytes)
        Creates a new ByteString by copying bytes from a ByteBuffer.
        Parameters:
        bytes - (undocumented)
        Returns:
        (undocumented)
      • apply

        public ByteString apply​(java.lang.String string)
        Creates a new ByteString by encoding a String as UTF-8.
        Parameters:
        string - (undocumented)
        Returns:
        (undocumented)
      • apply

        public ByteString apply​(java.lang.String string,
                                java.lang.String charset)
        Creates a new ByteString by encoding a String with a charset.
        Parameters:
        string - (undocumented)
        charset - (undocumented)
        Returns:
        (undocumented)
      • apply

        public ByteString apply​(java.lang.String string,
                                java.nio.charset.Charset charset)
        Creates a new ByteString by encoding a String with a charset.
        Parameters:
        string - (undocumented)
        charset - (undocumented)
        Returns:
        (undocumented)
      • fromArray

        public ByteString fromArray​(byte[] array)
        Creates a new ByteString by copying a byte array.
        Parameters:
        array - (undocumented)
        Returns:
        (undocumented)
      • 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.

        Parameters:
        array - (undocumented)
        Returns:
        (undocumented)
      • fromArray

        public ByteString fromArray​(byte[] array,
                                    int offset,
                                    int length)
        Creates a new ByteString by copying length bytes starting at offset from an Array.
        Parameters:
        array - (undocumented)
        offset - (undocumented)
        length - (undocumented)
        Returns:
        (undocumented)
      • 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.

        Parameters:
        array - (undocumented)
        offset - (undocumented)
        length - (undocumented)
        Returns:
        (undocumented)
      • fromInts

        public ByteString fromInts​(scala.collection.Seq<java.lang.Object> array)
        JAVA API Creates a new ByteString by copying an int array by converting from integral numbers to bytes.
        Parameters:
        array - (undocumented)
        Returns:
        (undocumented)
      • fromString

        public ByteString fromString​(java.lang.String string)
        Creates a new ByteString which will contain the UTF-8 representation of the given String
        Parameters:
        string - (undocumented)
        Returns:
        (undocumented)
      • fromString

        public ByteString fromString​(java.lang.String string,
                                     java.lang.String charset)
        Creates a new ByteString which will contain the representation of the given String in the given charset
        Parameters:
        string - (undocumented)
        charset - (undocumented)
        Returns:
        (undocumented)
      • fromString

        public ByteString fromString​(java.lang.String string,
                                     java.nio.charset.Charset charset)
        Creates a new ByteString which will contain the representation of the given String in the given charset
        Parameters:
        string - (undocumented)
        charset - (undocumented)
        Returns:
        (undocumented)
      • UTF_8

        public java.lang.String UTF_8()
        Standard "UTF-8" charset
        Returns:
        (undocumented)
      • fromByteBuffer

        public ByteString fromByteBuffer​(java.nio.ByteBuffer buffer)
        Creates a new ByteString by copying bytes out of a ByteBuffer.
        Parameters:
        buffer - (undocumented)
        Returns:
        (undocumented)
      • emptyByteString

        public ByteString emptyByteString()
        Java API
      • canBuildFrom

        public scala.collection.generic.CanBuildFrom<scala.collection.TraversableOnce<java.lang.Object>,​java.lang.Object,​ByteString> canBuildFrom()