com.vividsolutions.jump.util
Class StringUtil

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

public class StringUtil
extends java.lang.Object

Useful String-related utilities.


Constructor Summary
StringUtil()
           
 
Method Summary
static java.util.List blankStringList(int size)
          Returns a List of empty Strings.
static java.lang.String capitalize(java.lang.String word)
           
static java.lang.String classNameWithoutPackageQualifiers(java.lang.String className)
           
static java.lang.String classNameWithoutQualifiers(java.lang.String className)
           
static java.lang.String friendlyName(java.lang.Class c)
           
static java.util.List fromCommaDelimitedString(java.lang.String s)
          Converts the comma-delimited string into a List of trimmed strings.
static java.lang.String head(java.lang.String s, int lines)
           
static java.lang.String ies(int n)
          Warning: hinders internationalization
static java.lang.String insertSpaces(java.lang.String s)
           
static boolean isEmpty(java.lang.String value)
           
static boolean isNumber(java.lang.String token)
           
static java.lang.String limitLength(java.lang.String s, int maxLength)
           
static java.lang.String repeat(char c, int n)
           
static void replace(java.lang.StringBuffer orig, java.lang.String o, java.lang.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.
static java.lang.String replace(java.lang.String original, java.lang.String oldSubstring, java.lang.String newSubstring, boolean all)
          Returns original with occurrences of oldSubstring replaced by newSubstring.
static java.lang.String replaceAll(java.lang.String original, java.lang.String oldSubstring, java.lang.String newSubstring)
          Returns original with all occurrences of oldSubstring replaced by newSubstring
static java.lang.String s(int n)
          Warning: hinders internationalization
static java.lang.String split(java.lang.String s, int n)
          Line-wraps s by inserting a newline instead of the first space after the nth column.
static java.lang.String stackTrace(java.lang.Throwable t)
          Returns an throwable's stack trace
static java.lang.String substitute(java.lang.String string, java.lang.Object[] substitutions)
           
static java.lang.String toCommaDelimitedString(java.util.Collection c)
          Returns the elements of c separated by commas.
static java.lang.String toDelimitedString(java.util.Collection c, java.lang.String delimiter)
           
static java.lang.String toFriendlyName(java.lang.String className)
           
static java.lang.String toFriendlyName(java.lang.String className, java.lang.String substringToRemove)
           
static java.lang.String toTimeString(long milliseconds)
           
static java.lang.String uncapitalize(java.lang.String word)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtil

public StringUtil()
Method Detail

s

public static java.lang.String s(int n)
Warning: hinders internationalization


ies

public static java.lang.String ies(int n)
Warning: hinders internationalization


substitute

public static java.lang.String substitute(java.lang.String string,
                                          java.lang.Object[] substitutions)

classNameWithoutQualifiers

public static java.lang.String classNameWithoutQualifiers(java.lang.String className)

classNameWithoutPackageQualifiers

public static java.lang.String classNameWithoutPackageQualifiers(java.lang.String className)

repeat

public static java.lang.String repeat(char c,
                                      int n)

split

public static java.lang.String split(java.lang.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 java.lang.String capitalize(java.lang.String word)

uncapitalize

public static java.lang.String uncapitalize(java.lang.String word)

fromCommaDelimitedString

public static java.util.List fromCommaDelimitedString(java.lang.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 java.util.List 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 java.lang.String toFriendlyName(java.lang.String className)

friendlyName

public static java.lang.String friendlyName(java.lang.Class c)

toFriendlyName

public static java.lang.String toFriendlyName(java.lang.String className,
                                              java.lang.String substringToRemove)

insertSpaces

public static java.lang.String insertSpaces(java.lang.String s)

toCommaDelimitedString

public static java.lang.String toCommaDelimitedString(java.util.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 java.lang.String replaceAll(java.lang.String original,
                                          java.lang.String oldSubstring,
                                          java.lang.String newSubstring)
Returns original with all occurrences of oldSubstring replaced by newSubstring


replace

public static java.lang.String replace(java.lang.String original,
                                       java.lang.String oldSubstring,
                                       java.lang.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(java.lang.StringBuffer orig,
                           java.lang.String o,
                           java.lang.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 on UseNet


stackTrace

public static java.lang.String stackTrace(java.lang.Throwable t)
Returns an throwable's stack trace


head

public static java.lang.String head(java.lang.String s,
                                    int lines)

limitLength

public static java.lang.String limitLength(java.lang.String s,
                                           int maxLength)

isNumber

public static boolean isNumber(java.lang.String token)

toDelimitedString

public static java.lang.String toDelimitedString(java.util.Collection c,
                                                 java.lang.String delimiter)

toTimeString

public static java.lang.String toTimeString(long milliseconds)

isEmpty

public static boolean isEmpty(java.lang.String value)