com.evanmclean.evlib.escape
Class Esc

java.lang.Object
  extended by com.evanmclean.evlib.escape.Esc

public final class Esc
extends Object

Provides worker objects that can perform character escapes on strings to make them safe for various output (e.g. HTML, XML, Javascript).

The only difference between the html escape objects and their xhtml equivalents is that the EscHtml.textbr(Object) methods inserts a " <br> for HTML, and a "<br/>" for XHTML.

Author:
Evan McLean McLean Computer Services (see the overview for copyright and licensing.)

Field Summary
static EscCsv csv
           Makes a string safe to use as a field within a comma separated (CSV) file.
static EscHtml html
           HTML escaper that will convert the basic necessary characters required to make it safe for HTML (basically the <, >, " and & characters, plus unprintable control characters).
static EscHtml htmlAscii
           HTML escaper that will convert any character that falls outside of the printable ASCII set (as well as the standard <, >, " and & characters).
static EscHtml htmlFull
           HTML escaper that will convert any character that has a standard HTML entity code equivalent.
static EscHtml htmlMin
           HTML escaper that will convert the absolute minimum characters required to make it safe for HTML (basically the < and & characters, plus unprintable control characters).
static EscJava java
           Makes a string safe to use as a string literal inside a piece of Java code (does not add enclosing double quotes).
static EscJavascript javascript
           Makes a string safe to use as a string literal inside a piece of Javascript code (does not add enclosing double quotes).
static EscUrl url
           Makes a string safe to use as a URL parameter.
static EscHtml xhtml
           XHTML escaper that will convert the basic necessary characters required to make it safe for XHTML (basically the <, >, " and & characters, plus unprintable control characters).
static EscHtml xhtmlAscii
           XHTML escaper that will convert any character that falls outside of the printable ASCII set (as well as the standard <, >, " and & characters).
static EscHtml xhtmlFull
           XHTML escaper that will convert any character that has a standard XHTML entity code equivalent.
static EscXml xml
           XML escaper that will convert the standard characters required to make it safe for XML (basically the <, >, ", ' and & characters, plus unprintable control characters).
static EscXml xmlAscii
           XML escaper that will convert any character that falls outside of the printable ASCII set (as well as the standard <, >, ", ' and & characters).
 
Constructor Summary
Esc()
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

csv

public static final EscCsv csv

Makes a string safe to use as a field within a comma separated (CSV) file.

Basically encapsulates the string in a pair of double-quotes if the string contains any of the following:


htmlMin

public static final EscHtml htmlMin

HTML escaper that will convert the absolute minimum characters required to make it safe for HTML (basically the < and & characters, plus unprintable control characters).

See note about HTML and XHTML.


html

public static final EscHtml html

HTML escaper that will convert the basic necessary characters required to make it safe for HTML (basically the <, >, " and & characters, plus unprintable control characters). This is probably the one you'll want most of the time.

See note about HTML and XHTML.


htmlAscii

public static final EscHtml htmlAscii

HTML escaper that will convert any character that falls outside of the printable ASCII set (as well as the standard <, >, " and & characters).

See note about HTML and XHTML.


htmlFull

public static final EscHtml htmlFull

HTML escaper that will convert any character that has a standard HTML entity code equivalent. (e.g., "†" becomes "&dagger;".)

See note about HTML and XHTML.


xhtml

public static final EscHtml xhtml

XHTML escaper that will convert the basic necessary characters required to make it safe for XHTML (basically the <, >, " and & characters, plus unprintable control characters). This is probably the one you'll want most of the time.

See note about HTML and XHTML.


xhtmlAscii

public static final EscHtml xhtmlAscii

XHTML escaper that will convert any character that falls outside of the printable ASCII set (as well as the standard <, >, " and & characters).

See note about HTML and XHTML.


xhtmlFull

public static final EscHtml xhtmlFull

XHTML escaper that will convert any character that has a standard XHTML entity code equivalent. (e.g., "†" becomes "&dagger;".)

See note about HTML and XHTML.


xml

public static final EscXml xml

XML escaper that will convert the standard characters required to make it safe for XML (basically the <, >, ", ' and & characters, plus unprintable control characters). This is probably the one you'll want most of the time.


xmlAscii

public static final EscXml xmlAscii

XML escaper that will convert any character that falls outside of the printable ASCII set (as well as the standard <, >, ", ' and & characters).


url

public static final EscUrl url

Makes a string safe to use as a URL parameter.


java

public static final EscJava java

Makes a string safe to use as a string literal inside a piece of Java code (does not add enclosing double quotes).


javascript

public static final EscJavascript javascript

Makes a string safe to use as a string literal inside a piece of Javascript code (does not add enclosing double quotes).

Constructor Detail

Esc

public Esc()