Class ByteBufAsciiString

  • All Implemented Interfaces:
    io.netty.util.ReferenceCounted, java.lang.CharSequence, java.lang.Comparable<java.lang.CharSequence>

    public final class ByteBufAsciiString
    extends java.lang.Object
    implements java.lang.CharSequence, io.netty.util.ReferenceCounted, java.lang.Comparable<java.lang.CharSequence>
    A string implementation, similar to AsciiString, which is backed by a ByteBuf instead of a byte[] array.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteBufAsciiString​(byte[] bytes, int offset, int length, boolean copy)  
      ByteBufAsciiString​(io.netty.buffer.ByteBufAllocator alloc, byte[] bytes)  
      ByteBufAsciiString​(io.netty.buffer.ByteBufAllocator alloc, char[] value)
      Create a copy of value into this instance assuming ASCII encoding.
      ByteBufAsciiString​(io.netty.buffer.ByteBufAllocator alloc, char[] value, int start, int length)
      Create a copy of value into this instance assuming ASCII encoding.
      ByteBufAsciiString​(io.netty.buffer.ByteBufAllocator alloc, char[] value, java.nio.charset.Charset charset)
      Create a copy of value into this instance using the encoding type of charset.
      ByteBufAsciiString​(io.netty.buffer.ByteBufAllocator alloc, char[] value, java.nio.charset.Charset charset, int start, int length)
      Create a copy of value into a this instance using the encoding type of charset.
      ByteBufAsciiString​(io.netty.buffer.ByteBufAllocator alloc, java.lang.CharSequence charSequence)  
      ByteBufAsciiString​(io.netty.buffer.ByteBufAllocator alloc, java.lang.CharSequence value, int start, int length)
      Create a copy of value into this instance assuming ASCII encoding.
      ByteBufAsciiString​(io.netty.buffer.ByteBufAllocator alloc, java.lang.CharSequence value, java.nio.charset.Charset charset)
      Create a copy of value into this instance using the encoding type of charset.
      ByteBufAsciiString​(io.netty.buffer.ByteBufAllocator alloc, java.lang.CharSequence value, java.nio.charset.Charset charset, int start, int length)
      Create a copy of value into this instance using the encoding type of charset.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static char b2c​(byte b)  
      byte byteAt​(int index)  
      static byte c2b​(char c)  
      static byte c2b0​(char c)  
      char charAt​(int index)  
      int compareTo​(java.lang.CharSequence string)
      Compares the specified string to this string using the ASCII values of the characters.
      ByteBufAsciiString concat​(java.lang.CharSequence... strings)
      Concatenates this string and the specified string.
      boolean contains​(java.lang.CharSequence cs)
      Determines if this String contains the sequence of characters in the CharSequence passed.
      static boolean contains​(java.lang.CharSequence a, java.lang.CharSequence b)
      Determine if a contains b in a case sensitive manner.
      static boolean containsAllContentEqualsIgnoreCase​(java.util.Collection<java.lang.CharSequence> a, java.util.Collection<java.lang.CharSequence> b)
      Determine if a contains all of the values in b using contentEqualsIgnoreCase(CharSequence, CharSequence) to compare values.
      static boolean containsContentEqualsIgnoreCase​(java.util.Collection<java.lang.CharSequence> collection, java.lang.CharSequence value)
      Determine if collection contains value and using contentEqualsIgnoreCase(CharSequence, CharSequence) to compare values.
      static boolean containsIgnoreCase​(java.lang.CharSequence a, java.lang.CharSequence b)
      Determine if a contains b in a case insensitive manner.
      boolean contentEquals​(java.lang.CharSequence a)
      Compares a CharSequence to this String to determine if their contents are equal.
      static boolean contentEquals​(java.lang.CharSequence a, java.lang.CharSequence b)
      Returns true if the content of both CharSequence's are equals.
      boolean contentEqualsIgnoreCase​(java.lang.CharSequence string)
      Compares the specified string to this string ignoring the case of the characters and returns true if they are equal.
      static boolean contentEqualsIgnoreCase​(java.lang.CharSequence a, java.lang.CharSequence b)
      Returns true if both CharSequence's are equals when ignore the case.
      static ByteBufAsciiString copy​(io.netty.buffer.ByteBuf byteBuf, int index, int length)  
      boolean endsWith​(java.lang.CharSequence suffix)
      Compares the specified string to this string to determine if the specified string is a suffix.
      boolean equals​(java.lang.Object obj)  
      int forEachByte​(int index, int length, io.netty.util.ByteProcessor visitor)
      Iterates over the specified area of this buffer with the specified processor in ascending order.
      int forEachByte​(io.netty.util.ByteProcessor visitor)
      Iterates over the readable bytes of this buffer with the specified processor in ascending order.
      int forEachByteDesc​(int index, int length, io.netty.util.ByteProcessor visitor)
      Iterates over the specified area of this buffer with the specified processor in descending order.
      int forEachByteDesc​(io.netty.util.ByteProcessor visitor)
      Iterates over the readable bytes of this buffer with the specified processor in descending order.
      int hashCode()
      static int hashCode​(java.lang.CharSequence value)
      Returns the case-insensitive hash code of the specified string.
      int indexOf​(char ch, int start)
      Searches in this string for the index of the specified char ch.
      int indexOf​(java.lang.CharSequence string)
      Searches in this string for the first index of the specified string.
      static int indexOf​(java.lang.CharSequence cs, char searchChar, int start)
      Finds the first index in the CharSequence that matches the specified character.
      int indexOf​(java.lang.CharSequence subString, int start)
      Searches in this string for the index of the specified string.
      static int indexOfIgnoreCase​(java.lang.CharSequence str, java.lang.CharSequence searchStr, int startPos)
      Case in-sensitive find of the first index within a CharSequence from the specified position.
      static int indexOfIgnoreCaseAscii​(java.lang.CharSequence str, java.lang.CharSequence searchStr, int startPos)
      Case in-sensitive find of the first index within a CharSequence from the specified position.
      boolean isEmpty()
      Determine if this instance has 0 length.
      static boolean isUpperCase​(byte value)  
      static boolean isUpperCase​(char value)  
      int lastIndexOf​(java.lang.CharSequence string)
      Searches in this string for the last index of the specified string.
      int lastIndexOf​(java.lang.CharSequence subString, int start)
      Searches in this string for the index of the specified string.
      int length()  
      boolean matches​(java.lang.String expr)
      Determines whether this string matches a given regular expression.
      static ByteBufAsciiString read​(io.netty.buffer.ByteBuf byteBuf, int length)  
      static ByteBufAsciiString readBytes​(io.netty.buffer.ByteBuf byteBuf, int length)  
      static ByteBufAsciiString readRetainedSlice​(io.netty.buffer.ByteBuf byteBuf, int length)  
      int refCnt()  
      boolean regionMatches​(boolean ignoreCase, int thisStart, java.lang.CharSequence string, int start, int length)
      Compares the specified string to this string and compares the specified range of characters to determine if they are the same.
      boolean regionMatches​(int thisStart, java.lang.CharSequence string, int start, int length)
      Compares the specified string to this string and compares the specified range of characters to determine if they are the same.
      static boolean regionMatches​(java.lang.CharSequence cs, boolean ignoreCase, int csStart, java.lang.CharSequence string, int start, int length)
      This methods make regionMatches operation correctly for any chars in strings
      static boolean regionMatchesAscii​(java.lang.CharSequence cs, boolean ignoreCase, int csStart, java.lang.CharSequence string, int start, int length)
      This is optimized version of regionMatches for string with ASCII chars only
      boolean release()  
      boolean release​(int decrement)  
      ByteBufAsciiString replace​(char oldChar, char newChar)
      Copies this string replacing occurrences of the specified character with another character.
      ByteBufAsciiString retain()  
      ByteBufAsciiString retain​(int increment)  
      static ByteBufAsciiString slice​(io.netty.buffer.ByteBuf byteBuf, int index, int length)  
      ByteBufAsciiString[] split​(char delim)
      Splits the specified String with the specified delimiter..
      ByteBufAsciiString[] split​(java.lang.String expr, int max)
      Splits this string using the supplied regular expression expr.
      ByteBufAsciiString[] split​(java.util.regex.Pattern pattern)  
      ByteBufAsciiString[] split​(java.util.regex.Pattern pattern, int limit)  
      boolean startsWith​(java.lang.CharSequence prefix)
      Compares the specified string to this string to determine if the specified string is a prefix.
      boolean startsWith​(java.lang.CharSequence prefix, int start)
      Compares the specified string to this string, starting at the specified offset, to determine if the specified string is a prefix.
      static boolean startsWith​(java.lang.CharSequence string, java.lang.CharSequence prefix)
      Compares the specified string to this string to determine if the specified string is a prefix.
      static boolean startsWith​(java.lang.CharSequence string, java.lang.CharSequence prefix, int start)
      Compares the specified string to this string, starting at the specified offset, to determine if the specified string is a prefix.
      static boolean startsWithIgnoreCase​(java.lang.CharSequence string, java.lang.CharSequence prefix)
      Compares the specified string to this string to determine if the specified string is a prefix.
      static boolean startsWithIgnoreCase​(java.lang.CharSequence string, java.lang.CharSequence prefix, int start)  
      ByteBufAsciiString subSequence​(int start)
      Copies a range of characters into a new string.
      ByteBufAsciiString subSequence​(int start, int end)
      Copies a range of characters into a new string.
      ByteBufAsciiString subSequence​(int start, int end, boolean copy)
      Either copy or share a subset of underlying sub-sequence of bytes.
      io.netty.util.AsciiString toAsciiString()  
      byte[] toByteArray()
      Converts this string to a byte array.
      byte[] toByteArray​(int start, int end)
      Converts a subset of this string to a byte array.
      ByteBufAsciiString toLowerCase()
      Converts the characters in this string to lowercase, using the default Locale.
      java.lang.String toString()
      Translates the entire byte string to a String.
      java.lang.String toString​(int start)
      Translates the entire byte string to a String using the charset encoding.
      java.lang.String toString​(int start, int end)
      Translates the [start, end) range of this byte string to a String.
      io.netty.util.ReferenceCounted touch()  
      io.netty.util.ReferenceCounted touch​(java.lang.Object hint)  
      ByteBufAsciiString toUpperCase()
      Converts the characters in this string to uppercase, using the default Locale.
      ByteBufAsciiString trim()
      Duplicates this string removing white space characters from the beginning and end of the string, without copying.
      static java.lang.CharSequence trim​(java.lang.CharSequence c)
      Copies this string removing white space characters from the beginning and end of the string, and tries not to copy if possible.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.CharSequence

        chars, codePoints
    • Constructor Detail

      • ByteBufAsciiString

        public ByteBufAsciiString​(@Nonnull
                                  io.netty.buffer.ByteBufAllocator alloc,
                                  @Nonnull
                                  byte[] bytes)
      • ByteBufAsciiString

        public ByteBufAsciiString​(@Nonnull
                                  io.netty.buffer.ByteBufAllocator alloc,
                                  @Nonnull
                                  java.lang.CharSequence charSequence)
      • ByteBufAsciiString

        public ByteBufAsciiString​(@Nonnull
                                  io.netty.buffer.ByteBufAllocator alloc,
                                  @Nonnull
                                  java.lang.CharSequence value,
                                  int start,
                                  int length)
        Create a copy of value into this instance assuming ASCII encoding. The copy will start at index start and copy length bytes.
      • ByteBufAsciiString

        public ByteBufAsciiString​(@Nonnull
                                  io.netty.buffer.ByteBufAllocator alloc,
                                  @Nonnull
                                  char[] value)
        Create a copy of value into this instance assuming ASCII encoding.
      • ByteBufAsciiString

        public ByteBufAsciiString​(@Nonnull
                                  io.netty.buffer.ByteBufAllocator alloc,
                                  @Nonnull
                                  char[] value,
                                  int start,
                                  int length)
        Create a copy of value into this instance assuming ASCII encoding. The copy will start at index start and copy length bytes.
      • ByteBufAsciiString

        public ByteBufAsciiString​(@Nonnull
                                  io.netty.buffer.ByteBufAllocator alloc,
                                  @Nonnull
                                  char[] value,
                                  java.nio.charset.Charset charset)
        Create a copy of value into this instance using the encoding type of charset.
      • ByteBufAsciiString

        public ByteBufAsciiString​(@Nonnull
                                  io.netty.buffer.ByteBufAllocator alloc,
                                  @Nonnull
                                  char[] value,
                                  java.nio.charset.Charset charset,
                                  int start,
                                  int length)
        Create a copy of value into a this instance using the encoding type of charset. The copy will start at index start and copy length bytes.
      • ByteBufAsciiString

        public ByteBufAsciiString​(@Nonnull
                                  io.netty.buffer.ByteBufAllocator alloc,
                                  @Nonnull
                                  java.lang.CharSequence value,
                                  java.nio.charset.Charset charset)
        Create a copy of value into this instance using the encoding type of charset.
      • ByteBufAsciiString

        public ByteBufAsciiString​(@Nonnull
                                  io.netty.buffer.ByteBufAllocator alloc,
                                  @Nonnull
                                  java.lang.CharSequence value,
                                  java.nio.charset.Charset charset,
                                  int start,
                                  int length)
        Create a copy of value into this instance using the encoding type of charset. The copy will start at index start and copy length bytes.
      • ByteBufAsciiString

        public ByteBufAsciiString​(byte[] bytes,
                                  int offset,
                                  int length,
                                  boolean copy)
    • Method Detail

      • readBytes

        public static ByteBufAsciiString readBytes​(io.netty.buffer.ByteBuf byteBuf,
                                                   int length)
      • readRetainedSlice

        public static ByteBufAsciiString readRetainedSlice​(io.netty.buffer.ByteBuf byteBuf,
                                                           int length)
      • read

        public static ByteBufAsciiString read​(io.netty.buffer.ByteBuf byteBuf,
                                              int length)
      • copy

        public static ByteBufAsciiString copy​(io.netty.buffer.ByteBuf byteBuf,
                                              int index,
                                              int length)
      • slice

        public static ByteBufAsciiString slice​(io.netty.buffer.ByteBuf byteBuf,
                                               int index,
                                               int length)
      • forEachByte

        public int forEachByte​(io.netty.util.ByteProcessor visitor)
        Iterates over the readable bytes of this buffer with the specified processor in ascending order.
        Returns:
        -1 if the processor iterated to or beyond the end of the readable bytes. The last-visited index If the ByteProcessor.process(byte) returned false.
      • forEachByte

        public int forEachByte​(int index,
                               int length,
                               io.netty.util.ByteProcessor visitor)
        Iterates over the specified area of this buffer with the specified processor in ascending order. (i.e. index, (index + 1), .. (index + length - 1)).
        Returns:
        -1 if the processor iterated to or beyond the end of the specified area. The last-visited index If the ByteProcessor.process(byte) returned false.
      • forEachByteDesc

        public int forEachByteDesc​(io.netty.util.ByteProcessor visitor)
        Iterates over the readable bytes of this buffer with the specified processor in descending order.
        Returns:
        -1 if the processor iterated to or beyond the beginning of the readable bytes. The last-visited index If the ByteProcessor.process(byte) returned false.
      • forEachByteDesc

        public int forEachByteDesc​(int index,
                                   int length,
                                   io.netty.util.ByteProcessor visitor)
        Iterates over the specified area of this buffer with the specified processor in descending order. (i.e. (index + length - 1), (index + length - 2), ... index).
        Returns:
        -1 if the processor iterated to or beyond the beginning of the specified area. The last-visited index If the ByteProcessor.process(byte) returned false.
      • isEmpty

        public boolean isEmpty()
        Determine if this instance has 0 length.
      • length

        public int length()
        Specified by:
        length in interface java.lang.CharSequence
      • byteAt

        public byte byteAt​(int index)
      • toByteArray

        public byte[] toByteArray()
        Converts this string to a byte array.
      • toByteArray

        public byte[] toByteArray​(int start,
                                  int end)
        Converts a subset of this string to a byte array. The subset is defined by the range [start, end).
      • charAt

        public char charAt​(int index)
        Specified by:
        charAt in interface java.lang.CharSequence
      • contains

        public boolean contains​(java.lang.CharSequence cs)
        Determines if this String contains the sequence of characters in the CharSequence passed.
        Parameters:
        cs - the character sequence to search for.
        Returns:
        true if the sequence of characters are contained in this string, otherwise false.
      • compareTo

        public int compareTo​(@Nonnull
                             java.lang.CharSequence string)
        Compares the specified string to this string using the ASCII values of the characters. Returns 0 if the strings contain the same characters in the same order. Returns a negative integer if the first non-equal character in this string has an ASCII value which is less than the ASCII value of the character at the same position in the specified string, or if this string is a prefix of the specified string. Returns a positive integer if the first non-equal character in this string has a ASCII value which is greater than the ASCII value of the character at the same position in the specified string, or if the specified string is a prefix of this string.
        Specified by:
        compareTo in interface java.lang.Comparable<java.lang.CharSequence>
        Parameters:
        string - the string to compare.
        Returns:
        0 if the strings are equal, a negative integer if this string is before the specified string, or a positive integer if this string is after the specified string.
        Throws:
        java.lang.NullPointerException - if string is null.
      • concat

        public ByteBufAsciiString concat​(java.lang.CharSequence... strings)
        Concatenates this string and the specified string.
        Parameters:
        strings - the strings to concatenate
        Returns:
        a new string which is the concatenation of this string and the specified string.
      • endsWith

        public boolean endsWith​(java.lang.CharSequence suffix)
        Compares the specified string to this string to determine if the specified string is a suffix.
        Parameters:
        suffix - the suffix to look for.
        Returns:
        true if the specified string is a suffix of this string, false otherwise.
        Throws:
        java.lang.NullPointerException - if suffix is null.
      • contentEqualsIgnoreCase

        public boolean contentEqualsIgnoreCase​(java.lang.CharSequence string)
        Compares the specified string to this string ignoring the case of the characters and returns true if they are equal.
        Parameters:
        string - the string to compare.
        Returns:
        true if the specified string is equal to this string, false otherwise.
      • subSequence

        public ByteBufAsciiString subSequence​(int start)
        Copies a range of characters into a new string.
        Parameters:
        start - the offset of the first character (inclusive).
        Returns:
        a new string containing the characters from start to the end of the string.
        Throws:
        java.lang.IndexOutOfBoundsException - if start < 0 or start > length().
      • subSequence

        public ByteBufAsciiString subSequence​(int start,
                                              int end)
        Copies a range of characters into a new string.
        Specified by:
        subSequence in interface java.lang.CharSequence
        Parameters:
        start - the offset of the first character (inclusive).
        end - The index to stop at (exclusive).
        Returns:
        a new string containing the characters from start to the end of the string.
        Throws:
        java.lang.IndexOutOfBoundsException - if start < 0 or start > length().
      • subSequence

        public ByteBufAsciiString subSequence​(int start,
                                              int end,
                                              boolean copy)
        Either copy or share a subset of underlying sub-sequence of bytes.
        Parameters:
        start - the offset of the first character (inclusive).
        end - The index to stop at (exclusive).
        copy - If true then a copy of the underlying storage will be made. If false then the underlying storage will be shared.
        Returns:
        a new string containing the characters from start to the end of the string.
        Throws:
        java.lang.IndexOutOfBoundsException - if start < 0 or start > length().
      • indexOf

        public int indexOf​(java.lang.CharSequence string)
        Searches in this string for the first index of the specified string. The search for the string starts at the beginning and moves towards the end of this string.
        Parameters:
        string - the string to find.
        Returns:
        the index of the first character of the specified string in this string, -1 if the specified string is not a substring.
        Throws:
        java.lang.NullPointerException - if string is null.
      • indexOf

        public int indexOf​(java.lang.CharSequence subString,
                           int start)
        Searches in this string for the index of the specified string. The search for the string starts at the specified offset and moves towards the end of this string.
        Parameters:
        subString - the string to find.
        start - the starting offset.
        Returns:
        the index of the first character of the specified string in this string, -1 if the specified string is not a substring.
        Throws:
        java.lang.NullPointerException - if subString is null.
      • indexOf

        public int indexOf​(char ch,
                           int start)
        Searches in this string for the index of the specified char ch. The search for the char starts at the specified offset start and moves towards the end of this string.
        Parameters:
        ch - the char to find.
        start - the starting offset.
        Returns:
        the index of the first occurrence of the specified char ch in this string, -1 if found no occurrence.
      • lastIndexOf

        public int lastIndexOf​(java.lang.CharSequence string)
        Searches in this string for the last index of the specified string. The search for the string starts at the end and moves towards the beginning of this string.
        Parameters:
        string - the string to find.
        Returns:
        the index of the first character of the specified string in this string, -1 if the specified string is not a substring.
        Throws:
        java.lang.NullPointerException - if string is null.
      • lastIndexOf

        public int lastIndexOf​(java.lang.CharSequence subString,
                               int start)
        Searches in this string for the index of the specified string. The search for the string starts at the specified offset and moves towards the beginning of this string.
        Parameters:
        subString - the string to find.
        start - the starting offset.
        Returns:
        the index of the first character of the specified string in this string , -1 if the specified string is not a substring.
        Throws:
        java.lang.NullPointerException - if subString is null.
      • regionMatches

        public boolean regionMatches​(int thisStart,
                                     java.lang.CharSequence string,
                                     int start,
                                     int length)
        Compares the specified string to this string and compares the specified range of characters to determine if they are the same.
        Parameters:
        thisStart - the starting offset in this string.
        string - the string to compare.
        start - the starting offset in the specified string.
        length - the number of characters to compare.
        Returns:
        true if the ranges of characters are equal, false otherwise
        Throws:
        java.lang.NullPointerException - if string is null.
      • regionMatches

        public boolean regionMatches​(boolean ignoreCase,
                                     int thisStart,
                                     java.lang.CharSequence string,
                                     int start,
                                     int length)
        Compares the specified string to this string and compares the specified range of characters to determine if they are the same. When ignoreCase is true, the case of the characters is ignored during the comparison.
        Parameters:
        ignoreCase - specifies if case should be ignored.
        thisStart - the starting offset in this string.
        string - the string to compare.
        start - the starting offset in the specified string.
        length - the number of characters to compare.
        Returns:
        true if the ranges of characters are equal, false otherwise.
        Throws:
        java.lang.NullPointerException - if string is null.
      • replace

        public ByteBufAsciiString replace​(char oldChar,
                                          char newChar)
        Copies this string replacing occurrences of the specified character with another character.
        Parameters:
        oldChar - the character to replace.
        newChar - the replacement character.
        Returns:
        a new string with occurrences of oldChar replaced by newChar.
      • startsWith

        public boolean startsWith​(java.lang.CharSequence prefix)
        Compares the specified string to this string to determine if the specified string is a prefix.
        Parameters:
        prefix - the string to look for.
        Returns:
        true if the specified string is a prefix of this string, false otherwise
        Throws:
        java.lang.NullPointerException - if prefix is null.
      • startsWith

        public static boolean startsWith​(java.lang.CharSequence string,
                                         java.lang.CharSequence prefix)
        Compares the specified string to this string to determine if the specified string is a prefix.
        Parameters:
        prefix - the string to look for.
        Returns:
        true if the specified string is a prefix of this string, false otherwise
        Throws:
        java.lang.NullPointerException - if prefix is null.
      • startsWithIgnoreCase

        public static boolean startsWithIgnoreCase​(java.lang.CharSequence string,
                                                   java.lang.CharSequence prefix)
        Compares the specified string to this string to determine if the specified string is a prefix.
        Parameters:
        prefix - the string to look for.
        Returns:
        true if the specified string is a prefix of this string, false otherwise
        Throws:
        java.lang.NullPointerException - if prefix is null.
      • startsWith

        public boolean startsWith​(java.lang.CharSequence prefix,
                                  int start)
        Compares the specified string to this string, starting at the specified offset, to determine if the specified string is a prefix.
        Parameters:
        prefix - the string to look for.
        start - the starting offset.
        Returns:
        true if the specified string occurs in this string at the specified offset, false otherwise.
        Throws:
        java.lang.NullPointerException - if prefix is null.
      • startsWith

        public static boolean startsWith​(java.lang.CharSequence string,
                                         java.lang.CharSequence prefix,
                                         int start)
        Compares the specified string to this string, starting at the specified offset, to determine if the specified string is a prefix.
        Parameters:
        prefix - the string to look for.
        start - the starting offset.
        Returns:
        true if the specified string occurs in this string at the specified offset, false otherwise.
        Throws:
        java.lang.NullPointerException - if prefix is null.
      • startsWithIgnoreCase

        public static boolean startsWithIgnoreCase​(java.lang.CharSequence string,
                                                   java.lang.CharSequence prefix,
                                                   int start)
      • toLowerCase

        public ByteBufAsciiString toLowerCase()
        Converts the characters in this string to lowercase, using the default Locale.
        Returns:
        a new string containing the lowercase characters equivalent to the characters in this string.
      • toUpperCase

        public ByteBufAsciiString toUpperCase()
        Converts the characters in this string to uppercase, using the default Locale.
        Returns:
        a new string containing the uppercase characters equivalent to the characters in this string.
      • trim

        public static java.lang.CharSequence trim​(java.lang.CharSequence c)
        Copies this string removing white space characters from the beginning and end of the string, and tries not to copy if possible.
        Parameters:
        c - The CharSequence to trim.
        Returns:
        a new string with characters <= \\u0020 removed from the beginning and the end.
      • trim

        public ByteBufAsciiString trim()
        Duplicates this string removing white space characters from the beginning and end of the string, without copying.
        Returns:
        a new string with characters <= \\u0020 removed from the beginning and the end.
      • contentEquals

        public boolean contentEquals​(java.lang.CharSequence a)
        Compares a CharSequence to this String to determine if their contents are equal.
        Parameters:
        a - the character sequence to compare to.
        Returns:
        true if equal, otherwise false
      • matches

        public boolean matches​(java.lang.String expr)
        Determines whether this string matches a given regular expression.
        Parameters:
        expr - the regular expression to be matched.
        Returns:
        true if the expression matches, otherwise false.
        Throws:
        java.util.regex.PatternSyntaxException - if the syntax of the supplied regular expression is not valid.
        java.lang.NullPointerException - if expr is null.
      • split

        public ByteBufAsciiString[] split​(java.lang.String expr,
                                          int max)
        Splits this string using the supplied regular expression expr. The parameter max controls the behavior how many times the pattern is applied to the string.
        Parameters:
        expr - the regular expression used to divide the string.
        max - the number of entries in the resulting array.
        Returns:
        an array of Strings created by separating the string along matches of the regular expression.
        Throws:
        java.lang.NullPointerException - if expr is null.
        java.util.regex.PatternSyntaxException - if the syntax of the supplied regular expression is not valid.
        See Also:
        Pattern.split(CharSequence, int)
      • split

        public ByteBufAsciiString[] split​(@Nonnull
                                          java.util.regex.Pattern pattern,
                                          int limit)
      • split

        public ByteBufAsciiString[] split​(char delim)
        Splits the specified String with the specified delimiter..
      • hashCode

        public int hashCode()

        Provides a case-insensitive hash code for Ascii like byte strings.

        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toAsciiString

        @Nonnull
        public io.netty.util.AsciiString toAsciiString()
      • toString

        @Nonnull
        public java.lang.String toString()
        Translates the entire byte string to a String.
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class java.lang.Object
        See Also:
        toString(int)
      • toString

        public java.lang.String toString​(int start)
        Translates the entire byte string to a String using the charset encoding.
        See Also:
        toString(int, int)
      • toString

        public java.lang.String toString​(int start,
                                         int end)
        Translates the [start, end) range of this byte string to a String.
      • contentEquals

        public static boolean contentEquals​(java.lang.CharSequence a,
                                            java.lang.CharSequence b)
        Returns true if the content of both CharSequence's are equals. This only supports 8-bit ASCII.
      • hashCode

        public static int hashCode​(java.lang.CharSequence value)
        Returns the case-insensitive hash code of the specified string. Note that this method uses the same hashing algorithm with hashCode() so that you can put both AsciiStrings and arbitrary CharSequences into the same headers.
      • contains

        public static boolean contains​(java.lang.CharSequence a,
                                       java.lang.CharSequence b)
        Determine if a contains b in a case sensitive manner.
      • containsIgnoreCase

        public static boolean containsIgnoreCase​(java.lang.CharSequence a,
                                                 java.lang.CharSequence b)
        Determine if a contains b in a case insensitive manner.
      • contentEqualsIgnoreCase

        public static boolean contentEqualsIgnoreCase​(java.lang.CharSequence a,
                                                      java.lang.CharSequence b)
        Returns true if both CharSequence's are equals when ignore the case. This only supports 8-bit ASCII.
      • regionMatches

        public static boolean regionMatches​(java.lang.CharSequence cs,
                                            boolean ignoreCase,
                                            int csStart,
                                            java.lang.CharSequence string,
                                            int start,
                                            int length)
        This methods make regionMatches operation correctly for any chars in strings
        Parameters:
        cs - the CharSequence to be processed
        ignoreCase - specifies if case should be ignored.
        csStart - the starting offset in the cs CharSequence
        string - the CharSequence to compare.
        start - the starting offset in the specified string.
        length - the number of characters to compare.
        Returns:
        true if the ranges of characters are equal, false otherwise.
      • regionMatchesAscii

        public static boolean regionMatchesAscii​(java.lang.CharSequence cs,
                                                 boolean ignoreCase,
                                                 int csStart,
                                                 java.lang.CharSequence string,
                                                 int start,
                                                 int length)
        This is optimized version of regionMatches for string with ASCII chars only
        Parameters:
        cs - the CharSequence to be processed
        ignoreCase - specifies if case should be ignored.
        csStart - the starting offset in the cs CharSequence
        string - the CharSequence to compare.
        start - the starting offset in the specified string.
        length - the number of characters to compare.
        Returns:
        true if the ranges of characters are equal, false otherwise.
      • indexOfIgnoreCase

        public static int indexOfIgnoreCase​(java.lang.CharSequence str,
                                            java.lang.CharSequence searchStr,
                                            int startPos)

        Case in-sensitive find of the first index within a CharSequence from the specified position.

        A null CharSequence will return -1. A negative start position is treated as zero. An empty ("") search CharSequence always matches. A start position greater than the string length only matches an empty search CharSequence.

         AsciiString.indexOfIgnoreCase(null, *, *)          = -1
         AsciiString.indexOfIgnoreCase(*, null, *)          = -1
         AsciiString.indexOfIgnoreCase("", "", 0)           = 0
         AsciiString.indexOfIgnoreCase("aabaabaa", "A", 0)  = 0
         AsciiString.indexOfIgnoreCase("aabaabaa", "B", 0)  = 2
         AsciiString.indexOfIgnoreCase("aabaabaa", "AB", 0) = 1
         AsciiString.indexOfIgnoreCase("aabaabaa", "B", 3)  = 5
         AsciiString.indexOfIgnoreCase("aabaabaa", "B", 9)  = -1
         AsciiString.indexOfIgnoreCase("aabaabaa", "B", -1) = 2
         AsciiString.indexOfIgnoreCase("aabaabaa", "", 2)   = 2
         AsciiString.indexOfIgnoreCase("abc", "", 9)        = -1
         
        Parameters:
        str - the CharSequence to check, may be null
        searchStr - the CharSequence to find, may be null
        startPos - the start position, negative treated as zero
        Returns:
        the first index of the search CharSequence (always ≥ startPos), -1 if no match or null string input
      • indexOfIgnoreCaseAscii

        public static int indexOfIgnoreCaseAscii​(java.lang.CharSequence str,
                                                 java.lang.CharSequence searchStr,
                                                 int startPos)

        Case in-sensitive find of the first index within a CharSequence from the specified position. This method optimized and works correctly for ASCII CharSequences only

        A null CharSequence will return -1. A negative start position is treated as zero. An empty ("") search CharSequence always matches. A start position greater than the string length only matches an empty search CharSequence.

         AsciiString.indexOfIgnoreCase(null, *, *)          = -1
         AsciiString.indexOfIgnoreCase(*, null, *)          = -1
         AsciiString.indexOfIgnoreCase("", "", 0)           = 0
         AsciiString.indexOfIgnoreCase("aabaabaa", "A", 0)  = 0
         AsciiString.indexOfIgnoreCase("aabaabaa", "B", 0)  = 2
         AsciiString.indexOfIgnoreCase("aabaabaa", "AB", 0) = 1
         AsciiString.indexOfIgnoreCase("aabaabaa", "B", 3)  = 5
         AsciiString.indexOfIgnoreCase("aabaabaa", "B", 9)  = -1
         AsciiString.indexOfIgnoreCase("aabaabaa", "B", -1) = 2
         AsciiString.indexOfIgnoreCase("aabaabaa", "", 2)   = 2
         AsciiString.indexOfIgnoreCase("abc", "", 9)        = -1
         
        Parameters:
        str - the CharSequence to check, may be null
        searchStr - the CharSequence to find, may be null
        startPos - the start position, negative treated as zero
        Returns:
        the first index of the search CharSequence (always ≥ startPos), -1 if no match or null string input
      • indexOf

        public static int indexOf​(java.lang.CharSequence cs,
                                  char searchChar,
                                  int start)

        Finds the first index in the CharSequence that matches the specified character.

        Parameters:
        cs - the CharSequence to be processed, not null
        searchChar - the char to be searched for
        start - the start index, negative starts at the string start
        Returns:
        the index where the search char was found, -1 if char searchChar is not found or cs == null
      • isUpperCase

        public static boolean isUpperCase​(byte value)
      • isUpperCase

        public static boolean isUpperCase​(char value)
      • c2b

        public static byte c2b​(char c)
      • c2b0

        public static byte c2b0​(char c)
      • b2c

        public static char b2c​(byte b)
      • refCnt

        public int refCnt()
        Specified by:
        refCnt in interface io.netty.util.ReferenceCounted
      • retain

        public ByteBufAsciiString retain()
        Specified by:
        retain in interface io.netty.util.ReferenceCounted
      • retain

        public ByteBufAsciiString retain​(int increment)
        Specified by:
        retain in interface io.netty.util.ReferenceCounted
      • touch

        public io.netty.util.ReferenceCounted touch()
        Specified by:
        touch in interface io.netty.util.ReferenceCounted
      • touch

        public io.netty.util.ReferenceCounted touch​(java.lang.Object hint)
        Specified by:
        touch in interface io.netty.util.ReferenceCounted
      • release

        public boolean release()
        Specified by:
        release in interface io.netty.util.ReferenceCounted
      • release

        public boolean release​(int decrement)
        Specified by:
        release in interface io.netty.util.ReferenceCounted