Class StringUtil

java.lang.Object
com.vividsolutions.jump.util.StringUtil

public class StringUtil extends Object
Useful String-related utilities.
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • s

      public static String s(int n)
      Warning: hinders internationalization
    • ies

      public static String ies(int n)
      Warning: hinders internationalization
    • substitute

      public static String substitute(String string, Object[] substitutions)
    • classNameWithoutQualifiers

      public static String classNameWithoutQualifiers(String className)
    • classNameWithoutPackageQualifiers

      public static String classNameWithoutPackageQualifiers(String className)
    • repeat

      public static String repeat(char c, int n)
    • split

      public static String split(String s, int n)
      Line-wraps s by inserting a newline instead of the first space after the nth column. Word-wraps.
    • capitalize

      public static String capitalize(String word)
    • uncapitalize

      public static String uncapitalize(String word)
    • fromCommaDelimitedString

      public static List<String> fromCommaDelimitedString(String s)
      Converts the comma-delimited string into a List of trimmed strings.
      Parameters:
      s - a String with comma-delimited values
      Returns:
      a List of the Strings that were delimited by commas
    • blankStringList

      public static List<String> blankStringList(int size)
      Returns a List of empty Strings.
      Parameters:
      size - the size of the List to create
      Returns:
      a List of blank Strings
    • toFriendlyName

      public static String toFriendlyName(String className)
    • friendlyName

      public static String friendlyName(Class c)
    • toFriendlyName

      public static String toFriendlyName(String className, String substringToRemove)
    • insertSpaces

      public static String insertSpaces(String s)
    • toCommaDelimitedString

      public static String toCommaDelimitedString(Collection<?> c)
      Returns the elements of c separated by commas. If c is empty, an empty String will be returned.
      Parameters:
      c - a Collection of objects to convert to Strings and delimit by commas
      Returns:
      a String containing c's elements, delimited by commas
    • replaceAll

      public static String replaceAll(String original, String oldSubstring, String newSubstring)
      Returns original with all occurrences of oldSubstring replaced by newSubstring
    • replace

      public static String replace(String original, String oldSubstring, String newSubstring, boolean all)
      Returns original with occurrences of oldSubstring replaced by newSubstring. Set all to true to replace all occurrences, or false to replace the first occurrence only.
    • replace

      public static void replace(StringBuffer orig, String o, String n, boolean all)
      Replaces all instances of the String o with the String n in the StringBuffer orig if all is true, or only the first instance if all is false. Posted by Steve Chapel invalid input: '<'schapel@breakthr.com> on UseNet
    • stackTrace

      public static String stackTrace(Throwable t)
      Returns an throwable's stack trace
    • head

      public static String head(String s, int lines)
    • limitLength

      public static String limitLength(String s, int maxLength)
    • isNumber

      public static boolean isNumber(String token)
    • toDelimitedString

      public static String toDelimitedString(Collection<?> c, String delimiter)
    • toTimeString

      public static String toTimeString(long milliseconds)
    • isEmpty

      public static boolean isEmpty(String value)
    • fillString

      public static String fillString(int len, char ch)
    • toString

      public static String toString(double d)
      format Doubles to a String representation, cutting zeroes from the decimal end the minimum number of decimals is one, hinting the decimal nature of this number the maximimum number of decimal is hardcoded 12 and will be rounded eg. 1234.000 -> "1234.0", 1234.5600 -> "1234.56"
      Parameters:
      d - double value to format
      Returns:
      a formatted (rounded) string representation of the double