org.apache.jetspeed.util
Class StringUtils

java.lang.Object
  extended byorg.apache.jetspeed.util.StringUtils

public class StringUtils
extends java.lang.Object

This class provides static util methods for String manaipulation that aren't part of the default JDK functionalities.

Version:
$Id: StringUtils.java,v 1.11 2005/03/21 18:21:44 sgala Exp $
Author:
RaphaŽl Luta, Mark Orciuch

Constructor Summary
StringUtils()
           
 
Method Summary
static java.lang.String arrayToString(java.lang.String[] array, java.lang.String separators)
          Takes an array of tokens and converts into separator-separated string.
static java.lang.String removeChars(java.lang.String data, java.lang.String removeChars)
          Remove a given set of characters from a String.
static java.lang.StringBuffer replaceAll(java.lang.StringBuffer buffer, java.lang.String find, java.lang.String replacement)
          Replaces all the occurences of a substring found within a StringBuffer by a replacement string
static java.lang.String replaceAll(java.lang.String original, java.lang.String find, java.lang.String replacement)
          Deprecated. (Generates too much garbage)
static java.lang.String replaceVars(java.lang.String origString, java.util.Map vars)
          Performs variable substitution for a string.
static java.util.Map sortMapByValue(java.util.Map map)
          Returns map sorted by value
static java.util.ArrayList splitString(java.lang.String list, java.lang.String separator)
          Converts separated list into an array list
static java.util.Map splitStringPairs(java.lang.String list, java.lang.String separator, java.lang.String pairSeparator)
          Converts separated list of pairs into an array list
static java.util.Map splitStringPairs(java.lang.String list, java.lang.String separator, java.lang.String pairSeparator, boolean sortByValue)
          Same as splitStringPairs but returnes a sequenced map sorted by entry value
static java.lang.String[] stringToArray(java.lang.String str, java.lang.String separators)
          Converts a delimited string into an array of string tokens.
static java.lang.String stripExtension(java.lang.String filename)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtils

public StringUtils()
Method Detail

replaceAll

public static java.lang.String replaceAll(java.lang.String original,
                                          java.lang.String find,
                                          java.lang.String replacement)
Deprecated. (Generates too much garbage)

Replaces all the occurences of a substring found within a string by a replacement string

Parameters:
original - the string in where the replace will take place
find - the substring to find and replace
replacement - the replacement string for all occurences of find
Returns:
the original string where all the occurences of find are replaced by replacement

replaceAll

public static java.lang.StringBuffer replaceAll(java.lang.StringBuffer buffer,
                                                java.lang.String find,
                                                java.lang.String replacement)
Replaces all the occurences of a substring found within a StringBuffer by a replacement string

Parameters:
buffer - the StringBuffer in where the replace will take place
find - the substring to find and replace
replacement - the replacement string for all occurences of find
Returns:
the original StringBuffer where all the occurences of find are replaced by replacement

arrayToString

public static final java.lang.String arrayToString(java.lang.String[] array,
                                                   java.lang.String separators)
Takes an array of tokens and converts into separator-separated string.

Returns:
String A string containing tokens separated by seperator.

stringToArray

public static final java.lang.String[] stringToArray(java.lang.String str,
                                                     java.lang.String separators)
Converts a delimited string into an array of string tokens.

Returns:
String A string array of the original tokens.

removeChars

public static java.lang.String removeChars(java.lang.String data,
                                           java.lang.String removeChars)
Remove a given set of characters from a String.

Returns:
String The new string cleansed of 'removeChars'.

stripExtension

public static java.lang.String stripExtension(java.lang.String filename)

replaceVars

public static java.lang.String replaceVars(java.lang.String origString,
                                           java.util.Map vars)
Performs variable substitution for a string. String is scanned for ${variable_name} and if one is found, it is replaced with corresponding value from the vars hashtable.

Parameters:
origString - unmodified string
vars - Hashtable of replacement values
Returns:
modified string
Throws:
java.lang.Exception

splitString

public static java.util.ArrayList splitString(java.lang.String list,
                                              java.lang.String separator)
Converts separated list into an array list

Parameters:
list - list of values separated by the separator parameter
separator - defaults to comma
Returns:
array list

splitStringPairs

public static java.util.Map splitStringPairs(java.lang.String list,
                                             java.lang.String separator,
                                             java.lang.String pairSeparator)
Converts separated list of pairs into an array list

Parameters:
list - list of values separated by the separator parameter
separator - defaults to comma
Returns:
sorted map

splitStringPairs

public static java.util.Map splitStringPairs(java.lang.String list,
                                             java.lang.String separator,
                                             java.lang.String pairSeparator,
                                             boolean sortByValue)
Same as splitStringPairs but returnes a sequenced map sorted by entry value

Parameters:
list -
separator -
pairSeparator -
Returns:

sortMapByValue

public static java.util.Map sortMapByValue(java.util.Map map)
Returns map sorted by value

Parameters:
map -
Returns:


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.