Class ManStringExt
- java.lang.Object
-
- manifold.text.extensions.java.lang.String.ManStringExt
-
public class ManStringExt extends Object
Adapted from kotlin.text.String
-
-
Constructor Summary
Constructors Constructor Description ManStringExt()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringemptyIfNull(String thiz)Returns the string if it is not null, or the empty string otherwise.static StringpadEnd(String thiz, int length, char padChar)Pads the string to the specifiedlengthat the end with the specified character or space.static StringpadStart(String thiz, int length, char padChar)Pads the string to the specifiedlengthat the beginning with the specified character or space.static StringremovePrefix(String thiz, CharSequence prefix)If thiz string starts with the givenprefix, returns a copy of thiz string with the prefix removed.static StringremoveSuffix(String thiz, CharSequence suffix)If thiz string ends with the givensuffix, returns a copy of thiz string with the suffix removed.static CharSequenceremoveSurrounding(String thiz, CharSequence delimiter)Removes the givendelimiterstring from both the start and the end of thiz string if and only if it starts with and ends with thedelimiter.static StringremoveSurrounding(String thiz, CharSequence prefix, CharSequence suffix)Removes from a string both the givenprefixandsuffixif and only if it starts with theprefixand ends with thesuffix.static StringsubstringAfter(String thiz, char delimiter)Returns a substring after the first occurrence ofdelimiteror null if the string does not contain the delimiterstatic StringsubstringAfter(String thiz, String delimiter)Returns a substring after the first occurrence ofdelimiteror null if the string does not contain the delimiterstatic StringsubstringAfterLast(String thiz, char delimiter)Returns a substring after the last occurrence of delimiter or null if the string does not contain the delimiterstatic StringsubstringAfterLast(String thiz, String delimiter)Returns a substring after the last occurrence of delimiter or null if the string does not contain the delimiterstatic StringsubstringBefore(String thiz, char delimiter)Returns a substring before the first occurrence ofdelimiteror null if the string does not contain the delimiterstatic StringsubstringBefore(String thiz, String delimiter)Returns a substring before the first occurrence ofdelimiteror null if the string does not contain the delimiterstatic StringsubstringBeforeLast(String thiz, char delimiter)Returns a substring before the last occurrence ofdelimiteror null if the string does not contain the delimiterstatic StringsubstringBeforeLast(String thiz, String delimiter)Returns a substring before the last occurrence ofdelimiteror null if the string does not contain the delimiterstatic Stringtrim(String thiz, char... chars)Returns a string with leading and trailing characters from thecharsarray trimmed.static Stringtrim(String thiz, manifold.ext.rt.api.CharPredicate predicate)Returns a string with leading and trailing characters matching thepredicatetrimmed.static StringtrimEnd(String thiz)Returns a string with trailing whitespace removed.static StringtrimEnd(String thiz, char... chars)Returns a string with trailing characters from thecharsarray trimmed.static StringtrimEnd(String thiz, manifold.ext.rt.api.CharPredicate predicate)Returns a string with trailing characters matching thepredicatetrimmed.static StringtrimStart(String thiz)Returns a string with leading whitespace removed.static StringtrimStart(String thiz, char... chars)Returns a string with leading and trailing characters from thecharsarray trimmed.static StringtrimStart(String thiz, manifold.ext.rt.api.CharPredicate predicate)Returns a string with leading characters matching thepredicatetrimmed.
-
-
-
Method Detail
-
trim
public static String trim(String thiz, manifold.ext.rt.api.CharPredicate predicate)
Returns a string with leading and trailing characters matching thepredicatetrimmed.
-
trimStart
public static String trimStart(String thiz, manifold.ext.rt.api.CharPredicate predicate)
Returns a string with leading characters matching thepredicatetrimmed.
-
trimEnd
public static String trimEnd(String thiz, manifold.ext.rt.api.CharPredicate predicate)
Returns a string with trailing characters matching thepredicatetrimmed.
-
trim
public static String trim(String thiz, char... chars)
Returns a string with leading and trailing characters from thecharsarray trimmed.
-
trimStart
public static String trimStart(String thiz, char... chars)
Returns a string with leading and trailing characters from thecharsarray trimmed.
-
trimEnd
public static String trimEnd(String thiz, char... chars)
Returns a string with trailing characters from thecharsarray trimmed.
-
trimStart
public static String trimStart(String thiz)
Returns a string with leading whitespace removed.
-
trimEnd
public static String trimEnd(String thiz)
Returns a string with trailing whitespace removed.
-
padStart
public static String padStart(String thiz, int length, char padChar)
Pads the string to the specifiedlengthat the beginning 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 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 String padEnd(String thiz, int length, char padChar)
Pads the string to the specifiedlengthat the end 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 thelengthspecified.- Returns:
- Returns a string, of length at least
length, consisting of string prepended withpadCharas many times. as are necessary to reach that length.
-
emptyIfNull
public static String emptyIfNull(String thiz)
Returns the string if it is not null, or the empty string otherwise.
-
substringBefore
public static String substringBefore(String thiz, char delimiter)
Returns a substring before the first occurrence ofdelimiteror null if the string does not contain the delimiter
-
substringBefore
public static String substringBefore(String thiz, String delimiter)
Returns a substring before the first occurrence ofdelimiteror null if the string does not contain the delimiter
-
substringAfter
public static String substringAfter(String thiz, char delimiter)
Returns a substring after the first occurrence ofdelimiteror null if the string does not contain the delimiter
-
substringAfter
public static String substringAfter(String thiz, String delimiter)
Returns a substring after the first occurrence ofdelimiteror null if the string does not contain the delimiter
-
substringBeforeLast
public static String substringBeforeLast(String thiz, char delimiter)
Returns a substring before the last occurrence ofdelimiteror null if the string does not contain the delimiter
-
substringBeforeLast
public static String substringBeforeLast(String thiz, String delimiter)
Returns a substring before the last occurrence ofdelimiteror null if the string does not contain the delimiter
-
substringAfterLast
public static String substringAfterLast(String thiz, char delimiter)
Returns a substring after the last occurrence of delimiter or null if the string does not contain the delimiter
-
substringAfterLast
public static String substringAfterLast(String thiz, String delimiter)
Returns a substring after the last occurrence of delimiter or null if the string does not contain the delimiter
-
removePrefix
public static String removePrefix(String thiz, CharSequence prefix)
If thiz string starts with the givenprefix, returns a copy of thiz string with the prefix removed. Otherwise, returns thiz string.
-
removeSuffix
public static String removeSuffix(String thiz, CharSequence suffix)
If thiz string ends with the givensuffix, returns a copy of thiz string with the suffix removed. Otherwise, returns thiz string.
-
removeSurrounding
public static String removeSurrounding(String thiz, CharSequence prefix, CharSequence suffix)
Removes from a string both the givenprefixandsuffixif and only if it starts with theprefixand ends with thesuffix. Otherwise returns thiz string unchanged.
-
removeSurrounding
public static CharSequence removeSurrounding(String thiz, CharSequence delimiter)
Removes the givendelimiterstring from both the start and the end of thiz string if and only if it starts with and ends with thedelimiter. Otherwise returns thiz string unchanged.
-
-