soot.util
Class StringTools

java.lang.Object
  |
  +--soot.util.StringTools

public class StringTools
extends java.lang.Object

Utility methods for string manipulations commonly used in Soot.


Field Summary
static java.lang.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 java.lang.String getEscapedStringOf(java.lang.String fromString)
          Returns fromString, but with non-isalpha() characters printed as '\\unnnn'.
static java.lang.String getQuotedStringOf(java.lang.String fromString)
          Returns fromString, but with certain characters printed as if they were in a Java string literal.
static java.lang.String getUnEscapedStringOf(java.lang.String str)
          Returns a String de-escaping the \\unnnn representation for any escaped characters in the string.
static java.lang.String getUnicodeStringFromChar(char ch)
          Returns a String containing the escaped \\unnnn representation for ch.
static java.lang.String replaceAll(java.lang.String orig, java.lang.String toBeReplaced, java.lang.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 java.lang.String lineSeparator
Convenience field storing the system line separator.
Constructor Detail

StringTools

public StringTools()
Method Detail

getEscapedStringOf

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

getQuotedStringOf

public static java.lang.String getQuotedStringOf(java.lang.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 java.lang.String getUnicodeStringFromChar(char ch)
Returns a String containing the escaped \\unnnn representation for ch.

getUnEscapedStringOf

public static java.lang.String getUnEscapedStringOf(java.lang.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 java.lang.String replaceAll(java.lang.String orig,
                                          java.lang.String toBeReplaced,
                                          java.lang.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().