Class ManCharSequenceExt
- java.lang.Object
-
- manifold.text.extensions.java.lang.CharSequence.ManCharSequenceExt
-
public class ManCharSequenceExt extends Object
-
-
Constructor Summary
Constructors Constructor Description ManCharSequenceExt()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanall(CharSequence thiz, manifold.ext.rt.api.CharPredicate predicate)static booleancontains(CharSequence thiz, char ch)static booleancontains(CharSequence thiz, char ch, boolean ignoreCase)Returnstrueif this char sequence contains the specified characterchar.static booleancontains(CharSequence thiz, CharSequence other)static booleancontains(CharSequence thiz, CharSequence other, boolean ignoreCase)Returnstrueif this char sequence contains the specifiedothersequence of characters as a substring.static booleanendsWith(CharSequence thiz, char c)Returnstrueif this char sequence ends with the specified character.static booleanendsWith(CharSequence thiz, CharSequence suffix)Returnstrueif this char sequence ends with the specified suffix.static booleanendsWithIgnoreCase(CharSequence thiz, char c)static booleanendsWithIgnoreCase(CharSequence thiz, CharSequence suffix)Returnstrueif this char sequence ends with the specified prefix.static manifold.rt.api.util.Pair<Integer,String>findAnyOf(CharSequence thiz, Collection<String> strings)static manifold.rt.api.util.Pair<Integer,String>findAnyOf(CharSequence thiz, Collection<String> strings, int startIndex)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 specifiedstringsin this char sequence, starting from the specifiedstartIndexand optionally ignoring the case.static manifold.rt.api.util.Pair<Integer,String>findLastAnyOf(CharSequence thiz, Collection<String> strings)static manifold.rt.api.util.Pair<Integer,String>findLastAnyOf(CharSequence thiz, Collection<String> strings, int startIndex)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 specifiedstringsin this char sequence, starting from the specifiedstartIndexand optionally ignoring the case.static charfirst(CharSequence thiz)static charget(CharSequence thiz, int index)Implement the index operator to enable indexed access to characters such astext[i].static intindexOf(CharSequence thiz, int ch)static intindexOf(CharSequence thiz, int ch, boolean ignoreCase)static intindexOf(CharSequence thiz, int ch, int startIndex)static intindexOf(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 specifiedstartIndex.static intindexOf(CharSequence thiz, String string)static intindexOf(CharSequence thiz, String string, boolean ignoreCase)static intindexOf(CharSequence thiz, String string, int startIndex)static intindexOf(CharSequence thiz, String string, int startIndex, boolean ignoreCase)Returns the index within this char sequence of the first occurrence of the specifiedstring, starting from the specifiedstartIndex.static intindexOfAny(CharSequence thiz, char[] chars)static intindexOfAny(CharSequence thiz, char[] chars, int startIndex)static intindexOfAny(CharSequence thiz, char[] chars, int startIndex, boolean ignoreCase)Finds the index of the first occurrence of any of the specifiedcharsin this char sequence, starting from the specifiedstartIndexand optionally ignoring the case.static intindexOfAny(CharSequence thiz, Collection<String> strings)static intindexOfAny(CharSequence thiz, Collection<String> strings, int startIndex)static intindexOfAny(CharSequence thiz, Collection<String> strings, int startIndex, boolean ignoreCase)Finds the index of the first occurrence of any of the specifiedstringsin this char sequence, starting from the specifiedstartIndexand optionally ignoring the case.static booleanisBlank(CharSequence thiz)Returnstrueif this char sequence is empty or contains only whitespace characters.static booleanisEmpty(CharSequence thiz)Returnstrueif this char sequence is empty (contains no characters).static booleanisNotEmpty(CharSequence thiz)Returnstrueif this char sequence is not empty.static booleanisNullOrBlank(CharSequence thiz)Returnstrueif this nullable char sequence is eithernullor empty or consists solely of whitespace characters.static booleanisNullOrEmpty(CharSequence thiz)Returnstrueif this nullable char sequence is eithernullor empty.static charlast(CharSequence thiz)static intlastIndex(CharSequence thiz)Returns the index of the last character in the char sequence or -1 if it is empty.static intlastIndexOf(CharSequence thiz, int ch)static intlastIndexOf(CharSequence thiz, int ch, boolean ignoreCase)static intlastIndexOf(CharSequence thiz, int ch, int startIndex)static intlastIndexOf(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 specifiedstartIndex.static intlastIndexOf(CharSequence thiz, String string)static intlastIndexOf(CharSequence thiz, String string, boolean ignoreCase)static intlastIndexOf(CharSequence thiz, String string, int startIndex)static intlastIndexOf(CharSequence thiz, String string, int startIndex, boolean ignoreCase)Returns the index within this char sequence of the last occurrence of the specifiedstring, starting from the specifiedstartIndex.static intlastIndexOfAny(CharSequence thiz, char[] chars)static intlastIndexOfAny(CharSequence thiz, char[] chars, int startIndex)static intlastIndexOfAny(CharSequence thiz, char[] chars, int startIndex, boolean ignoreCase)Finds the index of the last occurrence of any of the specifiedcharsin this char sequence, starting from the specifiedstartIndexand optionally ignoring the case.static intlastIndexOfAny(CharSequence thiz, Collection<String> strings)static intlastIndexOfAny(CharSequence thiz, Collection<String> strings, int startIndex)static intlastIndexOfAny(CharSequence thiz, Collection<String> strings, int startIndex, boolean ignoreCase)Finds the index of the last occurrence of any of the specifiedstringsin this char sequence, starting from the specifiedstartIndexand optionally ignoring the case.static CharSequencepadEnd(CharSequence thiz, int length, char padChar)Returns a char sequence with content of this char sequence padded at the end to the specifiedlengthwith the specified character or space.static CharSequencepadStart(CharSequence thiz, int length, char padChar)Returns a char sequence with content of this char sequence padded at the beginning to the specifiedlengthwith the specified character or space.static CharSequenceremovePrefix(CharSequence thiz, CharSequence prefix)If this char sequence starts with the givenprefix, returns a new char sequence with the prefix removed.static CharSequenceremoveSuffix(CharSequence thiz, CharSequence suffix)If this char sequence ends with the givensuffix, returns a new char sequence with the suffix removed.static booleanstartsWith(CharSequence thiz, char c)Returnstrueif this char sequence starts with the specified character.static booleanstartsWith(CharSequence thiz, CharSequence prefix)Returnstrueif this char sequence starts with the specified prefix.static booleanstartsWithIgnoreCase(CharSequence thiz, char c)static booleanstartsWithIgnoreCase(CharSequence thiz, CharSequence prefix)Returnstrueif this char sequence starts with the specified prefix.static Stringsubstring(CharSequence thiz, int startIndex)static Stringsubstring(CharSequence thiz, int startIndex, int endIndex)Returns a substring of chars from a range of this char sequence starting at thestartIndexand ending right before theendIndex.static CharSequencetrim(CharSequence thiz, char... chars)Returns a sub sequence of this char sequence having leading and trailing characters from thecharsarray trimmed.static CharSequencetrim(CharSequence thiz, manifold.ext.rt.api.CharPredicate predicate)Returns a sub sequence of this char sequence having leading and trailing characters matching thepredicatetrimmed.static CharSequencetrimEnd(CharSequence thiz)Returns a sub sequence of this char sequence having trailing whitespace removed.static CharSequencetrimEnd(CharSequence thiz, char... chars)Returns a sub sequence of this char sequence having trailing characters from thecharsarray trimmed.static CharSequencetrimEnd(CharSequence thiz, manifold.ext.rt.api.CharPredicate predicate)Returns a sub sequence of this char sequence having trailing characters matching thepredicatetrimmed.static CharSequencetrimStart(CharSequence thiz)Returns a sub sequence of this char sequence having leading whitespace removed.static CharSequencetrimStart(CharSequence thiz, char... chars)Returns a sub sequence of this char sequence having leading and trailing characters from thecharsarray trimmed.static CharSequencetrimStart(CharSequence thiz, manifold.ext.rt.api.CharPredicate predicate)Returns a sub sequence of this char sequence having leading characters matching thepredicatetrimmed.
-
-
-
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 thepredicatetrimmed.
-
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 thepredicatetrimmed.
-
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 thepredicatetrimmed.
-
trim
public static CharSequence trim(CharSequence thiz, char... chars)
Returns a sub sequence of this char sequence having leading and trailing characters from thecharsarray trimmed.
-
trimStart
public static CharSequence trimStart(CharSequence thiz, char... chars)
Returns a sub sequence of this char sequence having leading and trailing characters from thecharsarray trimmed.
-
trimEnd
public static CharSequence trimEnd(CharSequence thiz, char... chars)
Returns a sub sequence of this char sequence having trailing characters from thecharsarray 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 specifiedlengthwith the specified character or space.- Parameters:
length- the desired string length.padChar- the character to pad string with, if it has length less than thelengthspecified.- Returns:
- Returns a string, of length at least
length, consisting of string prepended withpadCharas 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 specifiedlengthwith the specified character or space.- Parameters:
length- the desired string length.padChar- the character to pad string with, if it has length less than thelengthspecified.- Returns:
- Returns a string, of length at least
length, consisting of string prepended withpadCharas many times. as are necessary to reach that length.
-
isNullOrEmpty
public static boolean isNullOrEmpty(CharSequence thiz)
Returnstrueif this nullable char sequence is eithernullor empty.
-
isEmpty
public static boolean isEmpty(CharSequence thiz)
Returnstrueif this char sequence is empty (contains no characters).
-
isNotEmpty
public static boolean isNotEmpty(CharSequence thiz)
Returnstrueif this char sequence is not empty.
-
isBlank
public static boolean isBlank(CharSequence thiz)
Returnstrueif 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)
Returnstrueif this nullable char sequence is eithernullor 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 thestartIndexand ending right before theendIndex.- Parameters:
startIndex- the start index (inclusive).endIndex- the end index (exclusive). If not specified, the length of the char sequence is used.
-
substring
public static String substring(CharSequence thiz, int startIndex)
-
removePrefix
public static CharSequence removePrefix(CharSequence thiz, CharSequence prefix)
If this char sequence starts with the givenprefix, 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 givensuffix, returns a new char sequence with the suffix removed. Otherwise, returns a new char sequence with the same characters.
-
first
public static char first(CharSequence thiz)
-
last
public static char last(CharSequence thiz)
-
startsWith
public static boolean startsWith(CharSequence thiz, char c)
Returnstrueif 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)
Returnstrueif 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)
Returnstrueif this char sequence starts with the specified prefix.
-
startsWithIgnoreCase
public static boolean startsWithIgnoreCase(CharSequence thiz, CharSequence prefix)
Returnstrueif this char sequence starts with the specified prefix.
-
endsWith
public static boolean endsWith(CharSequence thiz, CharSequence suffix)
Returnstrueif this char sequence ends with the specified suffix.
-
endsWithIgnoreCase
public static boolean endsWithIgnoreCase(CharSequence thiz, CharSequence suffix)
Returnstrueif 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 specifiedcharsin this char sequence, starting from the specifiedstartIndexand optionally ignoring the case.- Parameters:
ignoreCase-trueto ignore character case when matching a character.- Returns:
- An index of the first occurrence of matched character from
charsor -1 if none ofcharsare 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 specifiedcharsin this char sequence, starting from the specifiedstartIndexand 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-trueto ignore character case when matching a character.- Returns:
- An index of the last occurrence of matched character from
charsor -1 if none ofcharsare found.
-
findAnyOf
public static manifold.rt.api.util.Pair<Integer,String> findAnyOf(CharSequence thiz, Collection<String> strings)
-
findAnyOf
public static manifold.rt.api.util.Pair<Integer,String> findAnyOf(CharSequence thiz, Collection<String> strings, int startIndex)
-
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 specifiedstringsin this char sequence, starting from the specifiedstartIndexand optionally ignoring the case.- Parameters:
ignoreCase-trueto ignore character case when matching a string.- Returns:
- A pair of an index of the first occurrence of matched string from
stringsand the string matched ornullif none ofstringsare found.To avoid ambiguous results when strings in
stringshave characters in common, this method proceeds from the beginning to the end of this string, and finds at each position the first element instringsthat matches this string at that position.
-
findLastAnyOf
public static manifold.rt.api.util.Pair<Integer,String> findLastAnyOf(CharSequence thiz, Collection<String> strings)
-
findLastAnyOf
public static manifold.rt.api.util.Pair<Integer,String> findLastAnyOf(CharSequence thiz, Collection<String> strings, int startIndex)
-
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 specifiedstringsin this char sequence, starting from the specifiedstartIndexand 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-trueto ignore character case when matching a string.- Returns:
- A pair of an index of the last occurrence of matched string from
stringsand the string matched ornullif none ofstringsare found.To avoid ambiguous results when strings in
stringshave characters in common, this method proceeds from the end toward the beginning of this string, and finds at each position the first element instringsthat matches this string at that position.
-
indexOfAny
public static int indexOfAny(CharSequence thiz, Collection<String> strings)
-
indexOfAny
public static int indexOfAny(CharSequence thiz, Collection<String> strings, int startIndex)
-
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 specifiedstringsin this char sequence, starting from the specifiedstartIndexand optionally ignoring the case.- Parameters:
ignoreCase-trueto ignore character case when matching a string.- Returns:
- An index of the first occurrence of matched string from
stringsor -1 if none ofstringsare found.To avoid ambiguous results when strings in
stringshave characters in common, this method proceeds from the beginning to the end of this string, and finds at each position the first element instringsthat matches this string at that position.
-
lastIndexOfAny
public static int lastIndexOfAny(CharSequence thiz, Collection<String> strings)
-
lastIndexOfAny
public static int lastIndexOfAny(CharSequence thiz, Collection<String> strings, int startIndex)
-
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 specifiedstringsin this char sequence, starting from the specifiedstartIndexand 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-trueto ignore character case when matching a string.- Returns:
- An index of the last occurrence of matched string from
stringsor -1 if none ofstringsare found.To avoid ambiguous results when strings in
stringshave characters in common, this method proceeds from the end toward the beginning of this string, and finds at each position the first element instringsthat 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 specifiedstartIndex.- Parameters:
ignoreCase-trueto ignore character case when matching a character.- Returns:
- An index of the first occurrence of
charor -1 if none is found.
-
indexOf
public static int indexOf(CharSequence thiz, String string)
-
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 specifiedstring, starting from the specifiedstartIndex.- Parameters:
ignoreCase-trueto ignore character case when matching a string.- Returns:
- An index of the first occurrence of
stringor `-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 specifiedstartIndex.- Parameters:
startIndex- The index of character to start searching at. The search proceeds backward toward the beginning of the string.ignoreCase-trueto ignore character case when matching a character.- Returns:
- An index of the first occurrence of
charor -1 if none is found.
-
lastIndexOf
public static int lastIndexOf(CharSequence thiz, String string)
-
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 specifiedstring, starting from the specifiedstartIndex.- Parameters:
startIndex- The index of character to start searching at. The search proceeds backward toward the beginning of the string.ignoreCase-trueto ignore character case when matching a string.- Returns:
- An index of the first occurrence of
stringor -1 if none is found.
-
contains
public static boolean contains(CharSequence thiz, CharSequence other)
-
contains
public static boolean contains(CharSequence thiz, CharSequence other, boolean ignoreCase)
Returnstrueif this char sequence contains the specifiedothersequence of characters as a substring.- Parameters:
ignoreCase-trueto 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)
Returnstrueif this char sequence contains the specified characterchar.- Parameters:
ignoreCase-trueto 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 astext[i].- Parameters:
index- the index of thecharvalue.- Returns:
- the
charvalue at the specified index of this string. The firstcharvalue is at index0. - Throws:
IndexOutOfBoundsException- if theindexargument is negative or not less than the length of this string.
-
-