Class 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 String emptyIfNull​(String thiz)
      Returns the string if it is not null, or the empty string otherwise.
      static String padEnd​(String thiz, int length, char padChar)
      Pads the string to the specified length at the end with the specified character or space.
      static String padStart​(String thiz, int length, char padChar)
      Pads the string to the specified length at the beginning with the specified character or space.
      static String removePrefix​(String thiz, CharSequence prefix)
      If thiz string starts with the given prefix, returns a copy of thiz string with the prefix removed.
      static String removeSuffix​(String thiz, CharSequence suffix)
      If thiz string ends with the given suffix, returns a copy of thiz string with the suffix removed.
      static CharSequence removeSurrounding​(String thiz, CharSequence delimiter)
      Removes the given delimiter string from both the start and the end of thiz string if and only if it starts with and ends with the delimiter.
      static String removeSurrounding​(String thiz, CharSequence prefix, CharSequence suffix)
      Removes from a string both the given prefix and suffix if and only if it starts with the prefix and ends with the suffix.
      static String substringAfter​(String thiz, char delimiter)
      Returns a substring after the first occurrence of delimiter or null if the string does not contain the delimiter
      static String substringAfter​(String thiz, String delimiter)
      Returns a substring after the first occurrence of delimiter or null if the string does not contain the delimiter
      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
      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
      static String substringBefore​(String thiz, char delimiter)
      Returns a substring before the first occurrence of delimiter or null if the string does not contain the delimiter
      static String substringBefore​(String thiz, String delimiter)
      Returns a substring before the first occurrence of delimiter or null if the string does not contain the delimiter
      static String substringBeforeLast​(String thiz, char delimiter)
      Returns a substring before the last occurrence of delimiter or null if the string does not contain the delimiter
      static String substringBeforeLast​(String thiz, String delimiter)
      Returns a substring before the last occurrence of delimiter or null if the string does not contain the delimiter
      static String trim​(String thiz, char... chars)
      Returns a string with leading and trailing characters from the chars array trimmed.
      static String trim​(String thiz, manifold.ext.rt.api.CharPredicate predicate)
      Returns a string with leading and trailing characters matching the predicate trimmed.
      static String trimEnd​(String thiz)
      Returns a string with trailing whitespace removed.
      static String trimEnd​(String thiz, char... chars)
      Returns a string with trailing characters from the chars array trimmed.
      static String trimEnd​(String thiz, manifold.ext.rt.api.CharPredicate predicate)
      Returns a string with trailing characters matching the predicate trimmed.
      static String trimStart​(String thiz)
      Returns a string with leading whitespace removed.
      static String trimStart​(String thiz, char... chars)
      Returns a string with leading and trailing characters from the chars array trimmed.
      static String trimStart​(String thiz, manifold.ext.rt.api.CharPredicate predicate)
      Returns a string with leading characters matching the predicate trimmed.
    • Constructor Detail

      • ManStringExt

        public ManStringExt()
    • Method Detail

      • trim

        public static String trim​(String thiz,
                                  manifold.ext.rt.api.CharPredicate predicate)
        Returns a string with leading and trailing characters matching the predicate trimmed.
      • trimStart

        public static String trimStart​(String thiz,
                                       manifold.ext.rt.api.CharPredicate predicate)
        Returns a string with leading characters matching the predicate trimmed.
      • trimEnd

        public static String trimEnd​(String thiz,
                                     manifold.ext.rt.api.CharPredicate predicate)
        Returns a string with trailing characters matching the predicate trimmed.
      • trim

        public static String trim​(String thiz,
                                  char... chars)
        Returns a string with leading and trailing characters from the chars array trimmed.
      • trimStart

        public static String trimStart​(String thiz,
                                       char... chars)
        Returns a string with leading and trailing characters from the chars array trimmed.
      • trimEnd

        public static String trimEnd​(String thiz,
                                     char... chars)
        Returns a string with trailing characters from the chars array 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 specified length at 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 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 String padEnd​(String thiz,
                                    int length,
                                    char padChar)
        Pads the string to the specified length at 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 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.
      • 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 of delimiter or 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 of delimiter or 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 of delimiter or 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 of delimiter or 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 of delimiter or 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 of delimiter or 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 given prefix, 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 given suffix, 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 given prefix and suffix if and only if it starts with the prefix and ends with the suffix. Otherwise returns thiz string unchanged.
      • removeSurrounding

        public static CharSequence removeSurrounding​(String thiz,
                                                     CharSequence delimiter)
        Removes the given delimiter string from both the start and the end of thiz string if and only if it starts with and ends with the delimiter. Otherwise returns thiz string unchanged.