org.codehaus.aspectwerkz.util
Class Strings

java.lang.Object
  extended by org.codehaus.aspectwerkz.util.Strings

public class Strings
extends Object

Utility methods for strings.

Author:
Jonas BonŽr

Method Summary
static String[] extractMethodSignature(String methodCallSignature)
          Parse a method signature or method call signature.
static boolean isNullOrEmpty(String s)
           
static String removeFormattingCharacters(String toBeEscaped)
          Removes newline, carriage return and tab characters from a string.
static String replaceSubString(String str, String oldToken, String newToken)
          Replaces all occurences of a substring inside a string.
static String replaceSubString(String str, String oldToken, String newToken, int max)
          Replaces all occurences of a substring inside a string.
static String[] splitString(String stringToSplit, String delimiter)
          String split on multicharacter delimiter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

removeFormattingCharacters

public static String removeFormattingCharacters(String toBeEscaped)
Removes newline, carriage return and tab characters from a string.

Parameters:
toBeEscaped - string to escape
Returns:
the escaped string

replaceSubString

public static String replaceSubString(String str,
                                      String oldToken,
                                      String newToken)
Replaces all occurences of a substring inside a string.

Parameters:
str - the string to search and replace in
oldToken - the string to search for
newToken - the string to replace newToken
Returns:
the new string

replaceSubString

public static String replaceSubString(String str,
                                      String oldToken,
                                      String newToken,
                                      int max)
Replaces all occurences of a substring inside a string.

Parameters:
str - the string to search and replace in
oldToken - the string to search for
newToken - the string to replace newToken
max - maximum number of values to replace (-1 => no maximum)
Returns:
the new string

splitString

public static final String[] splitString(String stringToSplit,
                                         String delimiter)
String split on multicharacter delimiter.

Written by Tim Quinn (tim.quinn@honeywell.com)

Parameters:
stringToSplit -
delimiter -
Returns:

extractMethodSignature

public static String[] extractMethodSignature(String methodCallSignature)
Parse a method signature or method call signature.
Given a call signature like "method(Type t)", extract the method name and param type and parameter name: [method, Type, t]
Given a signature like "method(X x, Y)", extract the method name and param name / param type - but leaving empty String if the information is not available: [method, X, x, Y, ""]

Parameters:
methodCallSignature -
Returns:
each element (2xp+1 sized) (see doc)

isNullOrEmpty

public static boolean isNullOrEmpty(String s)


Copyright © 2002-2005 Jonas Bonér, Alexandre Vasseur. All Rights Reserved.