Class Strings


  • public final class Strings
    extends Object
    • Method Detail

      • join

        @Deprecated
        public static String join​(Iterable<String> s,
                                  String on)
        Join an Iterable of Strings into a single string with a delimiter. For example, join(Arrays.asList("foo","","bar","x"), "|") would return "foo||bar|x"
        Parameters:
        s - an iterable of strings
        on - the delimiter
        Returns:
        a single joined string
      • join

        @Deprecated
        public static String join​(Iterator<String> iter,
                                  String on)
        Join an Iterator of Strings into a single string with a delimiter. For example, join(Arrays.asList("foo","","bar","x"), "|") would return "foo||bar|x"
        Parameters:
        iter - an iterator of strings
        on - the delimiter
        Returns:
        a single joined string
      • join

        @Deprecated
        public static String join​(String[] s,
                                  String on)
        Join an Array of Strings into a single string with a delimiter. For example, join(new String[] {"foo","","bar","x"}, "|") would return "foo||bar|x"
        Parameters:
        s - an iterable of strings
        on - the delimiter
        Returns:
        a single joined string
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(String s)
        Returns true if s.isEmpty() or s == null
        Parameters:
        s - a string that may be null or empty
        Returns:
        true if the string s is null or is empty
      • expandGlob

        public static List<String> expandGlob​(String globPattern)
        Expands a string with braces ("{}") into all of its possible permutations. We call anything inside of {} braces a "one-of" group. The only special characters in this glob syntax are '}', '{' and ',' The top-level pattern must not contain any commas, but a "one-of" group separates its elements with commas, and a one-of group may contain sub one-of groups. For example: start{a,b,c}end -> startaend, startbend, startcend start{a,{b,c},d} -> startaend, startbend, startcend, startdend {a,b,c} -> a, b, c start{a, b{x,y}} -> starta, startbx, startby
        Parameters:
        globPattern - a string in the format described above
        Returns:
        a list of all the strings that would satisfy globPattern, including duplicates
      • expandGlobToWildCardPaths

        public static List<WildcardPath> expandGlobToWildCardPaths​(String globPattern,
                                                                   char delim)
        Expands a string according to expandGlob(String), and then constructs a WildcardPath for each expanded result which can be used to match strings as described in WildcardPath.
        Parameters:
        globPattern - a String to be passed to expandGlob(String)
        delim - the delimeter used by WildcardPath
        Returns:
        a list of wildcard paths, one for each expanded result