soot.util
Class StringTools

java.lang.Object
  extended by soot.util.StringTools

public class StringTools
extends Object

Utility methods for string manipulations commonly used in Soot.


Field Summary
static String lineSeparator
          Convenience field storing the system line separator.
 
Constructor Summary
StringTools()
           
 
Method Summary
static char getCFormatChar(char c)
          Returns the canonical C-string representation of c.
static String getEscapedStringOf(String fromString)
          Returns fromString, but with non-isalpha() characters printed as '\\unnnn'.
static String getQuotedStringOf(String fromString)
          Returns fromString, but with certain characters printed as if they were in a Java string literal.
static String getUnEscapedStringOf(String str)
          Returns a String de-escaping the \\unnnn representation for any escaped characters in the string.
static String getUnicodeStringFromChar(char ch)
          Returns a String containing the escaped \\unnnn representation for ch.
static String replaceAll(String orig, String toBeReplaced, String replacement)
          Replaces all occurrences of the given substring with the given replacement string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lineSeparator

public static final String lineSeparator
Convenience field storing the system line separator.

Constructor Detail

StringTools

public StringTools()
Method Detail

getEscapedStringOf

public static String getEscapedStringOf(String fromString)
Returns fromString, but with non-isalpha() characters printed as '\\unnnn'. Used by SootClass to generate output.


getQuotedStringOf

public static String getQuotedStringOf(String fromString)
Returns fromString, but with certain characters printed as if they were in a Java string literal. Used by StringConstant.toString()


getUnicodeStringFromChar

public static String getUnicodeStringFromChar(char ch)
Returns a String containing the escaped \\unnnn representation for ch.


getUnEscapedStringOf

public static String getUnEscapedStringOf(String str)
Returns a String de-escaping the \\unnnn representation for any escaped characters in the string.


getCFormatChar

public static char getCFormatChar(char c)
Returns the canonical C-string representation of c.


replaceAll

public static String replaceAll(String orig,
                                String toBeReplaced,
                                String replacement)
Replaces all occurrences of the given substring with the given replacement string.

Parameters:
orig - The string in which all occurrences of the substring are to be replaced.
toBeReplaced - The substring which is to be replaced.
replacment - The string which is to replace toBeReplaced.
Returns:
The resulting String.

This method provides a facility similar to the String.replaceAll() method available in Java 1.4, except that it can only replace substrings rather than regular expressions. So if Soot ever abandons compatibility with pre-1.4 definitions of the Java API, it can also abandon replaceAllIn().