Package io.netty.util

Class AsciiString

java.lang.Object
io.netty.util.AsciiString
All Implemented Interfaces:
CharSequence, Comparable<CharSequence>

public final class AsciiString extends Object implements CharSequence, Comparable<CharSequence>
A string which has been encoded into a character encoding whose character always takes a single byte, similarly to ASCII. It internally keeps its content in a byte array unlike String, which uses a character array, for reduced memory footprint and faster data transfer from/to byte-based data structures such as a byte array and ByteBuffer. It is often used in conjunction with Headers that require a CharSequence.

This class was designed to provide an immutable array of bytes, and caches some internal state based upon the value of this array. However underlying access to this byte array is provided via not copying the array on construction or array(). If any changes are made to the underlying byte array it is the user's responsibility to call arrayChanged() so the state of this class can be reset.

  • Field Details

    • EMPTY_STRING

      public static final AsciiString EMPTY_STRING
    • MAX_CHAR_VALUE

      private static final char MAX_CHAR_VALUE
      See Also:
    • INDEX_NOT_FOUND

      public static final int INDEX_NOT_FOUND
      See Also:
    • value

      private final byte[] value
      If this value is modified outside the constructor then call arrayChanged().
    • offset

      private final int offset
      Offset into value that all operations should use when acting upon value.
    • length

      private final int length
      Length in bytes for value that we care about. This is independent from value.length because we may be looking at a subsection of the array.
    • hash

      private int hash
      The hash code is cached after it is first computed. It can be reset with arrayChanged().
    • string

      private String string
      Used to cache the toString() value.
    • CASE_INSENSITIVE_HASHER

      public static final HashingStrategy<CharSequence> CASE_INSENSITIVE_HASHER
    • CASE_SENSITIVE_HASHER

      public static final HashingStrategy<CharSequence> CASE_SENSITIVE_HASHER
  • Constructor Details

    • AsciiString

      public AsciiString(byte[] value)
      Initialize this byte string based upon a byte array. A copy will be made.
    • AsciiString

      public AsciiString(byte[] value, boolean copy)
      Initialize this byte string based upon a byte array. copy determines if a copy is made or the array is shared.
    • AsciiString

      public AsciiString(byte[] value, int start, int length, boolean copy)
      Construct a new instance from a byte[] array.
      Parameters:
      copy - true then a copy of the memory will be made. false the underlying memory will be shared.
    • AsciiString

      public AsciiString(ByteBuffer value)
      Create a copy of the underlying storage from value. The copy will start at Buffer.position() and copy Buffer.remaining() bytes.
    • AsciiString

      public AsciiString(ByteBuffer value, boolean copy)
      Initialize an instance based upon the underlying storage from value. There is a potential to share the underlying array storage if ByteBuffer.hasArray() is true. if copy is true a copy will be made of the memory. if copy is false the underlying storage will be shared, if possible.
    • AsciiString

      public AsciiString(ByteBuffer value, int start, int length, boolean copy)
      Initialize an AsciiString based upon the underlying storage from value. There is a potential to share the underlying array storage if ByteBuffer.hasArray() is true. if copy is true a copy will be made of the memory. if copy is false the underlying storage will be shared, if possible.
    • AsciiString

      public AsciiString(char[] value)
      Create a copy of value into this instance assuming ASCII encoding.
    • AsciiString

      public AsciiString(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.
    • AsciiString

      public AsciiString(char[] value, Charset charset)
      Create a copy of value into this instance using the encoding type of charset.
    • AsciiString

      public AsciiString(char[] value, 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.
    • AsciiString

      public AsciiString(CharSequence value)
      Create a copy of value into this instance assuming ASCII encoding.
    • AsciiString

      public AsciiString(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.
    • AsciiString

      public AsciiString(CharSequence value, Charset charset)
      Create a copy of value into this instance using the encoding type of charset.
    • AsciiString

      public AsciiString(CharSequence value, 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.
  • Method Details

    • forEachByte

      public int forEachByte(ByteProcessor visitor) throws Exception
      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.
      Throws:
      Exception
    • forEachByte

      public int forEachByte(int index, int length, ByteProcessor visitor) throws Exception
      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.
      Throws:
      Exception
    • forEachByte0

      private int forEachByte0(int index, int length, ByteProcessor visitor) throws Exception
      Throws:
      Exception
    • forEachByteDesc

      public int forEachByteDesc(ByteProcessor visitor) throws Exception
      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.
      Throws:
      Exception
    • forEachByteDesc

      public int forEachByteDesc(int index, int length, ByteProcessor visitor) throws Exception
      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.
      Throws:
      Exception
    • forEachByteDesc0

      private int forEachByteDesc0(int index, int length, ByteProcessor visitor) throws Exception
      Throws:
      Exception
    • byteAt

      public byte byteAt(int index)
    • isEmpty

      public boolean isEmpty()
      Determine if this instance has 0 length.
      Specified by:
      isEmpty in interface CharSequence
    • length

      public int length()
      The length in bytes of this instance.
      Specified by:
      length in interface CharSequence
    • arrayChanged

      public void arrayChanged()
      During normal use cases the AsciiString should be immutable, but if the underlying array is shared, and changes then this needs to be called.
    • array

      public byte[] array()
      This gives direct access to the underlying storage array. The toByteArray() should be preferred over this method. If the return value is changed then arrayChanged() must be called.
      See Also:
    • arrayOffset

      public int arrayOffset()
      The offset into array() for which data for this ByteString begins.
      See Also:
    • isEntireArrayUsed

      public boolean isEntireArrayUsed()
      Determine if the storage represented by array() is entirely used.
      See Also:
    • 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).
    • copy

      public void copy(int srcIdx, byte[] dst, int dstIdx, int length)
      Copies the content of this string to a byte array.
      Parameters:
      srcIdx - the starting offset of characters to copy.
      dst - the destination byte array.
      dstIdx - the starting offset in the destination byte array.
      length - the number of characters to copy.
    • charAt

      public char charAt(int index)
      Specified by:
      charAt in interface CharSequence
    • contains

      public boolean contains(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(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 Comparable<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:
      NullPointerException - if string is null.
    • concat

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

      public boolean endsWith(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:
      NullPointerException - if suffix is null.
    • contentEqualsIgnoreCase

      public boolean contentEqualsIgnoreCase(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.
    • misalignedEqualsIgnoreCase

      private boolean misalignedEqualsIgnoreCase(AsciiString other)
    • toCharArray

      public char[] toCharArray()
      Copies the characters in this string to a character array.
      Returns:
      a character array containing the characters of this string.
    • toCharArray

      public char[] toCharArray(int start, int end)
      Copies the characters in this string to a character array.
      Returns:
      a character array containing the characters of this string.
    • copy

      public void copy(int srcIdx, char[] dst, int dstIdx, int length)
      Copied the content of this string to a character array.
      Parameters:
      srcIdx - the starting offset of characters to copy.
      dst - the destination character array.
      dstIdx - the starting offset in the destination byte array.
      length - the number of characters to copy.
    • subSequence

      public AsciiString 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:
      IndexOutOfBoundsException - if start < 0 or start > length().
    • subSequence

      public AsciiString subSequence(int start, int end)
      Copies a range of characters into a new string.
      Specified by:
      subSequence in interface 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:
      IndexOutOfBoundsException - if start < 0 or start > length().
    • subSequence

      public AsciiString 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:
      IndexOutOfBoundsException - if start < 0 or start > length().
    • indexOf

      public int indexOf(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:
      NullPointerException - if string is null.
    • indexOf

      public int indexOf(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:
      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(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:
      NullPointerException - if string is null.
    • lastIndexOf

      public int lastIndexOf(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:
      NullPointerException - if subString is null.
    • regionMatches

      public boolean regionMatches(int thisStart, 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:
      NullPointerException - if string is null.
    • regionMatches

      public boolean regionMatches(boolean ignoreCase, int thisStart, 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:
      NullPointerException - if string is null.
    • replace

      public AsciiString 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(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:
      NullPointerException - if prefix is null.
    • startsWith

      public boolean startsWith(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:
      NullPointerException - if prefix is null.
    • toLowerCase

      public AsciiString 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 AsciiString 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 CharSequence trim(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 AsciiString 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(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(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:
      PatternSyntaxException - if the syntax of the supplied regular expression is not valid.
      NullPointerException - if expr is null.
    • split

      public AsciiString[] split(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:
      NullPointerException - if expr is null.
      PatternSyntaxException - if the syntax of the supplied regular expression is not valid.
      See Also:
    • split

      public AsciiString[] 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 Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

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

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

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

      public boolean parseBoolean()
    • parseChar

      public char parseChar()
    • parseChar

      public char parseChar(int start)
    • parseShort

      public short parseShort()
    • parseShort

      public short parseShort(int radix)
    • parseShort

      public short parseShort(int start, int end)
    • parseShort

      public short parseShort(int start, int end, int radix)
    • parseInt

      public int parseInt()
    • parseInt

      public int parseInt(int radix)
    • parseInt

      public int parseInt(int start, int end)
    • parseInt

      public int parseInt(int start, int end, int radix)
    • parseInt

      private int parseInt(int start, int end, int radix, boolean negative)
    • parseLong

      public long parseLong()
    • parseLong

      public long parseLong(int radix)
    • parseLong

      public long parseLong(int start, int end)
    • parseLong

      public long parseLong(int start, int end, int radix)
    • parseLong

      private long parseLong(int start, int end, int radix, boolean negative)
    • parseFloat

      public float parseFloat()
    • parseFloat

      public float parseFloat(int start, int end)
    • parseDouble

      public double parseDouble()
    • parseDouble

      public double parseDouble(int start, int end)
    • of

      public static AsciiString of(CharSequence string)
      Returns an AsciiString containing the given character sequence. If the given string is already a AsciiString, just returns the same instance.
    • cached

      public static AsciiString cached(String string)
      Returns an AsciiString containing the given string and retains/caches the input string for later use in toString(). Used for the constants (which already stored in the JVM's string table) and in cases where the guaranteed use of the toString() method.
    • hashCode

      public static int hashCode(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(CharSequence a, CharSequence b)
      Determine if a contains b in a case sensitive manner.
    • containsIgnoreCase

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

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

      public static boolean containsContentEqualsIgnoreCase(Collection<CharSequence> collection, CharSequence value)
      Determine if collection contains value and using contentEqualsIgnoreCase(CharSequence, CharSequence) to compare values.
      Parameters:
      collection - The collection to look for and equivalent element as value.
      value - The value to look for in collection.
      Returns:
      true if collection contains value according to contentEqualsIgnoreCase(CharSequence, CharSequence). false otherwise.
      See Also:
    • containsAllContentEqualsIgnoreCase

      public static boolean containsAllContentEqualsIgnoreCase(Collection<CharSequence> a, Collection<CharSequence> b)
      Determine if a contains all of the values in b using contentEqualsIgnoreCase(CharSequence, CharSequence) to compare values.
      Parameters:
      a - The collection under test.
      b - The values to test for.
      Returns:
      true if a contains all of the values in b using contentEqualsIgnoreCase(CharSequence, CharSequence) to compare values. false otherwise.
      See Also:
    • contentEquals

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

      private static AsciiString[] toAsciiStringArray(String[] jdkResult)
    • contains

      private static boolean contains(CharSequence a, CharSequence b, AsciiString.CharEqualityComparator cmp)
    • regionMatchesCharSequences

      private static boolean regionMatchesCharSequences(CharSequence cs, int csStart, CharSequence string, int start, int length, AsciiString.CharEqualityComparator charEqualityComparator)
    • regionMatches

      public static boolean regionMatches(CharSequence cs, boolean ignoreCase, int csStart, 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(CharSequence cs, boolean ignoreCase, int csStart, 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(CharSequence str, 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(CharSequence str, 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(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
    • equalsIgnoreCase

      private static boolean equalsIgnoreCase(byte a, byte b)
    • equalsIgnoreCase

      private static boolean equalsIgnoreCase(char a, char b)
    • toLowerCase

      private static byte toLowerCase(byte b)
    • toLowerCase

      public static char toLowerCase(char c)
      If the character is uppercase - converts the character to lowercase, otherwise returns the character as it is. Only for ASCII characters.
      Returns:
      lowercase ASCII character equivalent
    • toUpperCase

      private static byte toUpperCase(byte b)
    • isLowerCase

      private static boolean isLowerCase(byte value)
    • isUpperCase

      public static boolean isUpperCase(byte value)
    • isUpperCase

      public static boolean isUpperCase(char value)
    • c2b

      public static byte c2b(char c)
    • c2b0

      private static byte c2b0(char c)
    • b2c

      public static char b2c(byte b)