Class StringUtil

java.lang.Object
org.ofbiz.core.util.StringUtil

public class StringUtil extends Object
Misc String Utility Functions
Since:
2.0
Version:
$Revision: 1.1 $
Author:
Andy Zeneski
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • replaceString

      public static String replaceString(String mainString, String oldString, String newString)
      Replaces all occurances of oldString in mainString with newString
      Parameters:
      mainString - The original string
      oldString - The string to replace
      newString - The string to insert in place of the old
      Returns:
      mainString with all occurances of oldString replaced by newString
    • join

      public static String join(List<String> list, String delim)
      Creates a single string from a List of strings seperated by a delimiter.
      Parameters:
      list - a list of strings to join
      delim - the delimiter character(s) to use. (null value will join with no delimiter)
      Returns:
      a String of all values in the list seperated by the delimiter
    • split

      public static List<String> split(String str, String delim)
      Splits a String on a delimiter into a List of Strings.
      Parameters:
      str - the String to split
      delim - the delimiter character(s) to join on (null will split on whitespace)
      Returns:
      a list of Strings
    • quoteStrList

      public static List<String> quoteStrList(List<String> list)
      Encloses each of a List of Strings in quotes.
      Parameters:
      list - List of String(s) to quote.
    • strToMap

      public static Map<String,String> strToMap(String str)
      Creates a Map from an encoded name/value pair string
      Parameters:
      str - The string to decode and format
      Returns:
      a Map of name/value pairs
    • mapToStr

      public static String mapToStr(Map<?,?> map)
      Creates an encoded String from a Map of name/value pairs (MUST BE STRINGS!)
      Parameters:
      map - The Map of name/value pairs
      Returns:
      String The encoded String
    • cleanUpPathPrefix

      public static String cleanUpPathPrefix(String prefix)
      Make sure the string starts with a forward slash but does not end with one; converts back-slashes to forward-slashes; if in String is null or empty, returns zero length string.
    • removeSpaces

      public static String removeSpaces(String str)
      Removes all spaces from a string