Class ManCharSequenceExt


  • public class ManCharSequenceExt
    extends Object
    • Constructor Detail

      • ManCharSequenceExt

        public ManCharSequenceExt()
    • Method Detail

      • trim

        public static CharSequence trim​(CharSequence thiz,
                                        manifold.ext.rt.api.CharPredicate predicate)
        Returns a sub sequence of this char sequence having leading and trailing characters matching the predicate trimmed.
      • trimStart

        public static CharSequence trimStart​(CharSequence thiz,
                                             manifold.ext.rt.api.CharPredicate predicate)
        Returns a sub sequence of this char sequence having leading characters matching the predicate trimmed.
      • trimEnd

        public static CharSequence trimEnd​(CharSequence thiz,
                                           manifold.ext.rt.api.CharPredicate predicate)
        Returns a sub sequence of this char sequence having trailing characters matching the predicate trimmed.
      • trim

        public static CharSequence trim​(CharSequence thiz,
                                        char... chars)
        Returns a sub sequence of this char sequence having leading and trailing characters from the chars array trimmed.
      • trimStart

        public static CharSequence trimStart​(CharSequence thiz,
                                             char... chars)
        Returns a sub sequence of this char sequence having leading and trailing characters from the chars array trimmed.
      • trimEnd

        public static CharSequence trimEnd​(CharSequence thiz,
                                           char... chars)
        Returns a sub sequence of this char sequence having trailing characters from the chars array trimmed.
      • trimStart

        public static CharSequence trimStart​(CharSequence thiz)
        Returns a sub sequence of this char sequence having leading whitespace removed.
      • trimEnd

        public static CharSequence trimEnd​(CharSequence thiz)
        Returns a sub sequence of this char sequence having trailing whitespace removed.
      • padStart

        public static CharSequence padStart​(CharSequence thiz,
                                            int length,
                                            char padChar)
        Returns a char sequence with content of this char sequence padded at the beginning to the specified length with the specified character or space.
        Parameters:
        length - the desired string length.
        padChar - the character to pad string with, if it has length less than the length specified.
        Returns:
        Returns a string, of length at least length, consisting of string prepended with padChar as many times. as are necessary to reach that length.
      • padEnd

        public static CharSequence padEnd​(CharSequence thiz,
                                          int length,
                                          char padChar)
        Returns a char sequence with content of this char sequence padded at the end to the specified length with the specified character or space.
        Parameters:
        length - the desired string length.
        padChar - the character to pad string with, if it has length less than the length specified.
        Returns:
        Returns a string, of length at least length, consisting of string prepended with padChar as many times. as are necessary to reach that length.
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(CharSequence thiz)
        Returns true if this nullable char sequence is either null or empty.
      • isEmpty

        public static boolean isEmpty​(CharSequence thiz)
        Returns true if this char sequence is empty (contains no characters).
      • isNotEmpty

        public static boolean isNotEmpty​(CharSequence thiz)
        Returns true if this char sequence is not empty.
      • isBlank

        public static boolean isBlank​(CharSequence thiz)
        Returns true if this char sequence is empty or contains only whitespace characters.
      • all

        public static boolean all​(CharSequence thiz,
                                  manifold.ext.rt.api.CharPredicate predicate)
      • isNullOrBlank

        public static boolean isNullOrBlank​(CharSequence thiz)
        Returns true if this nullable char sequence is either null or empty or consists solely of whitespace characters.
      • lastIndex

        public static int lastIndex​(CharSequence thiz)
        Returns the index of the last character in the char sequence or -1 if it is empty.
      • substring

        public static String substring​(CharSequence thiz,
                                       int startIndex,
                                       int endIndex)
        Returns a substring of chars from a range of this char sequence starting at the startIndex and ending right before the endIndex.
        Parameters:
        startIndex - the start index (inclusive).
        endIndex - the end index (exclusive). If not specified, the length of the char sequence is used.
      • removePrefix

        public static CharSequence removePrefix​(CharSequence thiz,
                                                CharSequence prefix)
        If this char sequence starts with the given prefix, returns a new char sequence with the prefix removed. Otherwise, returns a new char sequence with the same characters.
      • removeSuffix

        public static CharSequence removeSuffix​(CharSequence thiz,
                                                CharSequence suffix)
        If this char sequence ends with the given suffix, returns a new char sequence with the suffix removed. Otherwise, returns a new char sequence with the same characters.
      • startsWith

        public static boolean startsWith​(CharSequence thiz,
                                         char c)
        Returns true if this char sequence starts with the specified character.
      • startsWithIgnoreCase

        public static boolean startsWithIgnoreCase​(CharSequence thiz,
                                                   char c)
      • endsWith

        public static boolean endsWith​(CharSequence thiz,
                                       char c)
        Returns true if this char sequence ends with the specified character.
      • endsWithIgnoreCase

        public static boolean endsWithIgnoreCase​(CharSequence thiz,
                                                 char c)
      • startsWith

        public static boolean startsWith​(CharSequence thiz,
                                         CharSequence prefix)
        Returns true if this char sequence starts with the specified prefix.
      • startsWithIgnoreCase

        public static boolean startsWithIgnoreCase​(CharSequence thiz,
                                                   CharSequence prefix)
        Returns true if this char sequence starts with the specified prefix.
      • endsWith

        public static boolean endsWith​(CharSequence thiz,
                                       CharSequence suffix)
        Returns true if this char sequence ends with the specified suffix.
      • endsWithIgnoreCase

        public static boolean endsWithIgnoreCase​(CharSequence thiz,
                                                 CharSequence suffix)
        Returns true if this char sequence ends with the specified prefix.
      • indexOfAny

        public static int indexOfAny​(CharSequence thiz,
                                     char[] chars)
      • indexOfAny

        public static int indexOfAny​(CharSequence thiz,
                                     char[] chars,
                                     int startIndex)
      • indexOfAny

        public static int indexOfAny​(CharSequence thiz,
                                     char[] chars,
                                     int startIndex,
                                     boolean ignoreCase)
        Finds the index of the first occurrence of any of the specified chars in this char sequence, starting from the specified startIndex and optionally ignoring the case.
        Parameters:
        ignoreCase - true to ignore character case when matching a character.
        Returns:
        An index of the first occurrence of matched character from chars or -1 if none of chars are found.
      • lastIndexOfAny

        public static int lastIndexOfAny​(CharSequence thiz,
                                         char[] chars)
      • lastIndexOfAny

        public static int lastIndexOfAny​(CharSequence thiz,
                                         char[] chars,
                                         int startIndex)
      • lastIndexOfAny

        public static int lastIndexOfAny​(CharSequence thiz,
                                         char[] chars,
                                         int startIndex,
                                         boolean ignoreCase)
        Finds the index of the last occurrence of any of the specified chars in this char sequence, starting from the specified startIndex and optionally ignoring the case.
        Parameters:
        startIndex - The index of character to start searching at. The search proceeds backward toward the beginning of the string.
        ignoreCase - true to ignore character case when matching a character.
        Returns:
        An index of the last occurrence of matched character from chars or -1 if none of chars are found.
      • findAnyOf

        public static manifold.rt.api.util.Pair<Integer,​String> findAnyOf​(CharSequence thiz,
                                                                                Collection<String> strings,
                                                                                int startIndex,
                                                                                boolean ignoreCase)
        Finds the first occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
        Parameters:
        ignoreCase - true to ignore character case when matching a string.
        Returns:
        A pair of an index of the first occurrence of matched string from strings and the string matched or null if none of strings are found.

        To avoid ambiguous results when strings in strings have characters in common, this method proceeds from the beginning to the end of this string, and finds at each position the first element in strings that matches this string at that position.

      • findLastAnyOf

        public static manifold.rt.api.util.Pair<Integer,​String> findLastAnyOf​(CharSequence thiz,
                                                                                    Collection<String> strings,
                                                                                    int startIndex,
                                                                                    boolean ignoreCase)
        Finds the last occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
        Parameters:
        startIndex - The index of character to start searching at. The search proceeds backward toward the beginning of the string.
        ignoreCase - true to ignore character case when matching a string.
        Returns:
        A pair of an index of the last occurrence of matched string from strings and the string matched or null if none of strings are found.

        To avoid ambiguous results when strings in strings have characters in common, this method proceeds from the end toward the beginning of this string, and finds at each position the first element in strings that matches this string at that position.

      • indexOfAny

        public static int indexOfAny​(CharSequence thiz,
                                     Collection<String> strings,
                                     int startIndex,
                                     boolean ignoreCase)
        Finds the index of the first occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
        Parameters:
        ignoreCase - true to ignore character case when matching a string.
        Returns:
        An index of the first occurrence of matched string from strings or -1 if none of strings are found.

        To avoid ambiguous results when strings in strings have characters in common, this method proceeds from the beginning to the end of this string, and finds at each position the first element in strings that matches this string at that position.

      • lastIndexOfAny

        public static int lastIndexOfAny​(CharSequence thiz,
                                         Collection<String> strings,
                                         int startIndex,
                                         boolean ignoreCase)
        Finds the index of the last occurrence of any of the specified strings in this char sequence, starting from the specified startIndex and optionally ignoring the case.
        Parameters:
        startIndex - The index of character to start searching at. The search proceeds backward toward the beginning of the string.
        ignoreCase - true to ignore character case when matching a string.
        Returns:
        An index of the last occurrence of matched string from strings or -1 if none of strings are found.

        To avoid ambiguous results when strings in strings have characters in common, this method proceeds from the end toward the beginning of this string, and finds at each position the first element in strings that matches this string at that position.

      • indexOf

        public static int indexOf​(CharSequence thiz,
                                  int ch)
      • indexOf

        public static int indexOf​(CharSequence thiz,
                                  int ch,
                                  boolean ignoreCase)
      • indexOf

        public static int indexOf​(CharSequence thiz,
                                  int ch,
                                  int startIndex)
      • indexOf

        public static int indexOf​(CharSequence thiz,
                                  int ch,
                                  int startIndex,
                                  boolean ignoreCase)
        Returns the index within this string of the first occurrence of the specified character, starting from the specified startIndex.
        Parameters:
        ignoreCase - true to ignore character case when matching a character.
        Returns:
        An index of the first occurrence of char or -1 if none is found.
      • indexOf

        public static int indexOf​(CharSequence thiz,
                                  String string,
                                  boolean ignoreCase)
      • indexOf

        public static int indexOf​(CharSequence thiz,
                                  String string,
                                  int startIndex)
      • indexOf

        public static int indexOf​(CharSequence thiz,
                                  String string,
                                  int startIndex,
                                  boolean ignoreCase)
        Returns the index within this char sequence of the first occurrence of the specified string, starting from the specified startIndex.
        Parameters:
        ignoreCase - true to ignore character case when matching a string.
        Returns:
        An index of the first occurrence of string or `-1` if none is found.
      • lastIndexOf

        public static int lastIndexOf​(CharSequence thiz,
                                      int ch)
      • lastIndexOf

        public static int lastIndexOf​(CharSequence thiz,
                                      int ch,
                                      boolean ignoreCase)
      • lastIndexOf

        public static int lastIndexOf​(CharSequence thiz,
                                      int ch,
                                      int startIndex)
      • lastIndexOf

        public static int lastIndexOf​(CharSequence thiz,
                                      int ch,
                                      int startIndex,
                                      boolean ignoreCase)
        Returns the index within this char sequence of the last occurrence of the specified character, starting from the specified startIndex.
        Parameters:
        startIndex - The index of character to start searching at. The search proceeds backward toward the beginning of the string.
        ignoreCase - true to ignore character case when matching a character.
        Returns:
        An index of the first occurrence of char or -1 if none is found.
      • lastIndexOf

        public static int lastIndexOf​(CharSequence thiz,
                                      String string,
                                      boolean ignoreCase)
      • lastIndexOf

        public static int lastIndexOf​(CharSequence thiz,
                                      String string,
                                      int startIndex)
      • lastIndexOf

        public static int lastIndexOf​(CharSequence thiz,
                                      String string,
                                      int startIndex,
                                      boolean ignoreCase)
        Returns the index within this char sequence of the last occurrence of the specified string, starting from the specified startIndex.
        Parameters:
        startIndex - The index of character to start searching at. The search proceeds backward toward the beginning of the string.
        ignoreCase - true to ignore character case when matching a string.
        Returns:
        An index of the first occurrence of string or -1 if none is found.
      • contains

        public static boolean contains​(CharSequence thiz,
                                       CharSequence other,
                                       boolean ignoreCase)
        Returns true if this char sequence contains the specified other sequence of characters as a substring.
        Parameters:
        ignoreCase - true to ignore character case when comparing strings.
      • contains

        public static boolean contains​(CharSequence thiz,
                                       char ch)
      • contains

        public static boolean contains​(CharSequence thiz,
                                       char ch,
                                       boolean ignoreCase)
        Returns true if this char sequence contains the specified character char.
        Parameters:
        ignoreCase - true to ignore character case when comparing characters.
      • get

        public static char get​(CharSequence thiz,
                               int index)
        Implement the index operator to enable indexed access to characters such as text[i].
        Parameters:
        index - the index of the char value.
        Returns:
        the char value at the specified index of this string. The first char value is at index 0.
        Throws:
        IndexOutOfBoundsException - if the index argument is negative or not less than the length of this string.