com.neoworks.util
Class Escaper

java.lang.Object
  |
  +--com.neoworks.util.Escaper

public class Escaper
extends java.lang.Object

Escaper contains methods to escape text and sql.

Version:
0.1
Author:
Nigel Atkinson nigel@neoworks.com

Method Summary
static java.lang.String SQLEscape(java.lang.String s)
          Convert a string so it can be included in an SQL statement, by replacing each apostrophe with a pair of apostrophes
static java.lang.String stringEscape(java.lang.String in)
          Escape a String (replace " with \")
static java.lang.String XMLEscape(java.lang.String in)
          Escape special characters in a String value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

XMLEscape

public static java.lang.String XMLEscape(java.lang.String in)
Escape special characters in a String value.

Parameters:
in - The input string
Returns:
The XML representation of the string
This static method converts a Unicode string to a string containing only ASCII characters, in which non-ASCII characters are represented by the usual XML/HTML escape conventions (for example, "<" becomes "&lt;").
Note: if the input consists solely of ASCII or Latin-1 characters, the output will be equally valid in XML and HTML. Otherwise it will be valid only in XML.

SQLEscape

public static java.lang.String SQLEscape(java.lang.String s)
Convert a string so it can be included in an SQL statement, by replacing each apostrophe with a pair of apostrophes

Parameters:
s - The string to escape
Returns:
The escaped string

stringEscape

public static java.lang.String stringEscape(java.lang.String in)
Escape a String (replace " with \")

Parameters:
in - The String to escape
Returns:
The escaped String