FindBugs™ 1.3.9

edu.umd.cs.findbugs.util
Class Strings

java.lang.Object
  extended by edu.umd.cs.findbugs.util.Strings

public class Strings
extends java.lang.Object

A class for static String utility methods.

Author:
Brian Cole

Constructor Summary
Strings()
           
 
Method Summary
static java.lang.String escapeXml(java.lang.String s)
          Escape XML entities and illegal characters in the given string.
static void initializeEscapeMap()
          Initializes the map of characters to be escaped and their corresponding escape sequences.
static boolean initializeUnescapePattern()
          Initialize regular expressions used in unescaping.
static java.lang.String replace(java.lang.String source, java.lang.String find, java.lang.String repl)
          This is intended to be semantically equivalent to source.replace(find, repl) but also compatible with JDK 1.4.
static java.lang.String toString(java.lang.Object[] a)
          This is intended to be equivalent to Arrays.toString(a) but also compatible with JDK 1.4.
static java.lang.String trimComma(java.lang.String s)
          Trim trailing comma from given string.
static java.lang.String unescapeXml(java.lang.String s)
          Unescape XML entities and illegal characters in the given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Strings

public Strings()
Method Detail

replace

public static java.lang.String replace(java.lang.String source,
                                       java.lang.String find,
                                       java.lang.String repl)
This is intended to be semantically equivalent to source.replace(find, repl) but also compatible with JDK 1.4.

Parameters:
source - The String on which to operate
find - The literal substring to be replaced
repl - The literal replacement substring
Returns:
The resultant String after substitution
Throws:
java.lang.NullPointerException - if any of the arguments are null
java.lang.IllegalArgumentException - if find has zero length
See Also:
String.replace(CharSequence target, CharSequence replacement)

toString

public static java.lang.String toString(java.lang.Object[] a)
This is intended to be equivalent to Arrays.toString(a) but also compatible with JDK 1.4. This concatenates the results of calling String.valueOf() on each element of the array, so this won't work well for multi-dimensional arrays.

See Also:
String.valueOf(Object), Arrays.toString(Object[]), Arrays.deepToString(Object[])

trimComma

public static java.lang.String trimComma(java.lang.String s)
Trim trailing comma from given string.

Parameters:
s - a string
Returns:
the same string with trailing comma trimmed (if any)

initializeEscapeMap

public static void initializeEscapeMap()
Initializes the map of characters to be escaped and their corresponding escape sequences. This method will be invoked automatically the first time a string is escaped/unescaped.

See Also:

escapeXml

public static java.lang.String escapeXml(java.lang.String s)
Escape XML entities and illegal characters in the given string. This enhances the functionality of org.apache.commons.lang.StringEscapeUtils.escapeXml by escaping low-valued unprintable characters, which are not permitted by the W3C XML 1.0 specification.

Parameters:
s - a string
Returns:
the same string with characters not permitted by the XML specification escaped
See Also:
org.apache.commons.lang.StringEscapeUtils javadoc

initializeUnescapePattern

public static boolean initializeUnescapePattern()
Initialize regular expressions used in unescaping. This method will be invoked automatically the first time a string is unescaped.


unescapeXml

public static java.lang.String unescapeXml(java.lang.String s)
Unescape XML entities and illegal characters in the given string. This enhances the functionality of org.apache.commons.lang.StringEscapeUtils.unescapeXml by unescaping low-valued unprintable characters, which are not permitted by the W3C XML 1.0 specification.

Parameters:
s - a string
Returns:
the same string with XML entities/escape sequences unescaped
See Also:
org.apache.commons.lang.StringEscapeUtils javadoc

FindBugs™ 1.3.9

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.