Interface ByteArray

  • All Superinterfaces:
    java.lang.Iterable<java.lang.Byte>

    public interface ByteArray
    extends java.lang.Iterable<java.lang.Byte>
    This interface provides access to various methods for querying and manipulating byte arrays.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void append​(byte b)
      This method appends the provided byte.
      void append​(byte[] bytes)
      This method appends the provided bytes.
      void append​(ByteArray byteArray)
      This method appends the provided bytes.
      void append​(java.lang.String text)
      This method appends the provided text as UTF-8 encoded bytes.
      static ByteArray byteArray()
      Create a new ByteArray
      static ByteArray byteArray​(byte[] bytes)
      Create a new ByteArray that wraps the provided byte array
      static ByteArray byteArray​(java.lang.String text)
      Create a new ByteArray from the provided UTF-8 encoded text.
      ByteArray copy()
      Create a deep copy of the ByteArray
      default int countMatches​(byte[] searchTerm)
      This method searches the data in the ByteArray and counts all matches for a specified term.
      default int countMatches​(byte[] searchTerm, boolean caseSensitive)
      This method searches the data in the ByteArray and counts all matches for a specified term.
      int countMatches​(byte[] searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
      This method searches the data in the ByteArray and counts all matches for a specified term.
      default int countMatches​(java.lang.String searchTerm)
      This method searches the data in the ByteArray and counts all matches for a specified term.
      default int countMatches​(java.lang.String searchTerm, boolean caseSensitive)
      This method searches the data in the ByteArray and counts all matches for a specified term.
      int countMatches​(java.lang.String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
      This method searches the data in the ByteArray and counts all matches for a specified term.
      byte getByte​(int index)
      This method returns a byte stored at the provided index.
      byte[] getBytes()
      This method returns all bytes.
      byte[] getBytes​(int startIndexInclusive, int endIndexExclusive)
      This method returns all bytes between the start index (inclusive) and the end index (exclusive).
      byte[] getBytes​(Range range)
      This method returns all bytes in the specified range.
      default int indexOf​(byte[] searchTerm)
      This method searches the data in the ByteArray for the first occurrence of a specified term.
      default int indexOf​(byte[] searchTerm, boolean caseSensitive)
      This method searches the data in the ByteArray for the first occurrence of a specified term.
      int indexOf​(byte[] searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
      This method searches the data in the ByteArray for the first occurrence of a specified term.
      default int indexOf​(java.lang.String searchTerm)
      This method searches the data in the ByteArray for the first occurrence of a specified term.
      default int indexOf​(java.lang.String searchTerm, boolean caseSensitive)
      This method searches the data in the ByteArray for the first occurrence of a specified term.
      int indexOf​(java.lang.String searchTerm, boolean caseSensitive, int startIndexInclusive, int endIndexExclusive)
      This method searches the data in the ByteArray for the first occurrence of a specified term.
      int length()
      This method returns the number of bytes stored in the ByteArray.
      void setByte​(int index, byte b)
      This method sets the byte at the provided index to the provided byte.
      void setBytes​(int index, byte[] bytes)
      This method sets bytes starting at the specified index to the provided bytes.
      void setBytes​(int index, ByteArray byteArray)
      This method sets bytes starting at the specified index to the provided bytes.
      java.lang.String toString()
      This method can be used to convert the bytes of the ByteArray into UTF-8 encoded String form.
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
    • Method Detail

      • byteArray

        static ByteArray byteArray()
        Create a new ByteArray
        Returns:
        New empty ByteArray.
      • byteArray

        static ByteArray byteArray​(byte[] bytes)
        Create a new ByteArray that wraps the provided byte array
        Parameters:
        bytes - Byte array to wrap.
        Returns:
        New ByteArray wrapping the provided byte array.
      • byteArray

        static ByteArray byteArray​(java.lang.String text)
        Create a new ByteArray from the provided UTF-8 encoded text.
        Parameters:
        text - UTF-8 encoded text.
        Returns:
        New ByteArray holding a copy of the text as UTF-8 encoded bytes.
      • getByte

        byte getByte​(int index)
        This method returns a byte stored at the provided index.
        Parameters:
        index - Index of the byte to be retrieved.
        Returns:
        The byte at the index.
      • setByte

        void setByte​(int index,
                     byte b)
        This method sets the byte at the provided index to the provided byte.
        Parameters:
        index - Index of the byte to be set.
        b - The byte to be set.
      • getBytes

        byte[] getBytes()
        This method returns all bytes.
        Returns:
        All bytes.
      • getBytes

        byte[] getBytes​(int startIndexInclusive,
                        int endIndexExclusive)
        This method returns all bytes between the start index (inclusive) and the end index (exclusive).
        Parameters:
        startIndexInclusive - The inclusive start index of retrieved range.
        endIndexExclusive - The exclusive end index of retrieved range.
        Returns:
        All bytes in the specified range.
      • getBytes

        byte[] getBytes​(Range range)
        This method returns all bytes in the specified range.
        Parameters:
        range - The Range of bytes to be returned.
        Returns:
        All bytes in the specified range.
      • setBytes

        void setBytes​(int index,
                      byte[] bytes)
        This method sets bytes starting at the specified index to the provided bytes.
        Parameters:
        index - The index of the first byte to set.
        bytes - The bytes to be set.
      • setBytes

        void setBytes​(int index,
                      ByteArray byteArray)
        This method sets bytes starting at the specified index to the provided bytes.
        Parameters:
        index - The index of the first byte to set.
        byteArray - The ByteArray object holding the provided bytes.
      • append

        void append​(byte b)
        This method appends the provided byte.
        Parameters:
        b - The byte to be appended.
      • append

        void append​(byte[] bytes)
        This method appends the provided bytes.
        Parameters:
        bytes - The bytes to append.
      • append

        void append​(java.lang.String text)
        This method appends the provided text as UTF-8 encoded bytes.
        Parameters:
        text - The UTF-8 encoded string to append.
      • append

        void append​(ByteArray byteArray)
        This method appends the provided bytes.
        Parameters:
        byteArray - The bytes to append.
      • length

        int length()
        This method returns the number of bytes stored in the ByteArray.
        Returns:
        Length of the ByteArray.
      • copy

        ByteArray copy()
        Create a deep copy of the ByteArray
        Returns:
        New ByteArray with a deep copy of the wrapped bytes.
      • indexOf

        default int indexOf​(byte[] searchTerm)
        This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
        Parameters:
        searchTerm - The value to be searched for.
        Returns:
        The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
      • indexOf

        default int indexOf​(java.lang.String searchTerm)
        This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
        Parameters:
        searchTerm - The value to be searched for.
        Returns:
        The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
      • indexOf

        default int indexOf​(byte[] searchTerm,
                            boolean caseSensitive)
        This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
        Parameters:
        searchTerm - The value to be searched for.
        caseSensitive - Flags whether the search is case-sensitive.
        Returns:
        The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
      • indexOf

        default int indexOf​(java.lang.String searchTerm,
                            boolean caseSensitive)
        This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
        Parameters:
        searchTerm - The value to be searched for.
        caseSensitive - Flags whether the search is case-sensitive.
        Returns:
        The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
      • indexOf

        int indexOf​(byte[] searchTerm,
                    boolean caseSensitive,
                    int startIndexInclusive,
                    int endIndexExclusive)
        This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
        Parameters:
        searchTerm - The value to be searched for.
        caseSensitive - Flags whether the search is case-sensitive.
        startIndexInclusive - The inclusive start index for the search.
        endIndexExclusive - The exclusive end index for the search.
        Returns:
        The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
      • indexOf

        int indexOf​(java.lang.String searchTerm,
                    boolean caseSensitive,
                    int startIndexInclusive,
                    int endIndexExclusive)
        This method searches the data in the ByteArray for the first occurrence of a specified term. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf(String) works on String-based data.
        Parameters:
        searchTerm - The value to be searched for.
        caseSensitive - Flags whether the search is case-sensitive.
        startIndexInclusive - The inclusive start index for the search.
        endIndexExclusive - The exclusive end index for the search.
        Returns:
        The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.
      • countMatches

        default int countMatches​(byte[] searchTerm)
        This method searches the data in the ByteArray and counts all matches for a specified term.
        Parameters:
        searchTerm - The value to be searched for.
        Returns:
        The count of all matches of the pattern
      • countMatches

        default int countMatches​(java.lang.String searchTerm)
        This method searches the data in the ByteArray and counts all matches for a specified term.
        Parameters:
        searchTerm - The value to be searched for.
        Returns:
        The count of all matches of the pattern
      • countMatches

        default int countMatches​(byte[] searchTerm,
                                 boolean caseSensitive)
        This method searches the data in the ByteArray and counts all matches for a specified term.
        Parameters:
        searchTerm - The value to be searched for.
        caseSensitive - Flags whether the search is case-sensitive.
        Returns:
        The count of all matches of the pattern
      • countMatches

        default int countMatches​(java.lang.String searchTerm,
                                 boolean caseSensitive)
        This method searches the data in the ByteArray and counts all matches for a specified term.
        Parameters:
        searchTerm - The value to be searched for.
        caseSensitive - Flags whether the search is case-sensitive.
        Returns:
        The count of all matches of the pattern
      • countMatches

        int countMatches​(byte[] searchTerm,
                         boolean caseSensitive,
                         int startIndexInclusive,
                         int endIndexExclusive)
        This method searches the data in the ByteArray and counts all matches for a specified term.
        Parameters:
        searchTerm - The value to be searched for.
        caseSensitive - Flags whether the search is case-sensitive.
        startIndexInclusive - The inclusive start index for the search.
        endIndexExclusive - The exclusive end index for the search.
        Returns:
        The count of all matches of the pattern within the specified bounds
      • countMatches

        int countMatches​(java.lang.String searchTerm,
                         boolean caseSensitive,
                         int startIndexInclusive,
                         int endIndexExclusive)
        This method searches the data in the ByteArray and counts all matches for a specified term.
        Parameters:
        searchTerm - The value to be searched for.
        caseSensitive - Flags whether the search is case-sensitive.
        startIndexInclusive - The inclusive start index for the search.
        endIndexExclusive - The exclusive end index for the search.
        Returns:
        The count of all matches of the pattern within the specified bounds
      • toString

        java.lang.String toString()
        This method can be used to convert the bytes of the ByteArray into UTF-8 encoded String form.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The converted data in UTF-8 encoding.