org.eigenbase.xom
Class StringEscaper

java.lang.Object
  extended by org.eigenbase.xom.StringEscaper
All Implemented Interfaces:
Cloneable

public class StringEscaper
extends Object
implements Cloneable

StringEscaper is a utility for replacing special characters with escape sequences in strings. Initially, a StringEscaper starts out as an identity transform in the "mutable" state. Call defineEscape as many times as necessary to set up mappings, and then call makeImmutable() before using appendEscapedString to actually apply the defined transform. Or, use one of the global mappings pre-defined here.

 

Field Summary
static StringEscaper htmlEscaper
           
static StringEscaper urlArgEscaper
           
static StringEscaper urlEscaper
           
static StringEscaper xmlEscaper
           
static StringEscaper xmlNumericEscaper
           
 
Constructor Summary
StringEscaper()
          Identity transform
 
Method Summary
 void appendEscapedString(String s, StringBuffer sb)
          Apply an immutable transformation to the given string, writing the results to a string buffer.
protected  Object clone()
           
 void defineEscape(char from, String to)
          Map character "from" to escape sequence "to"
 String escapeString(String s)
          Apply an immutable transformation to the given string.
 StringEscaper getMutableClone()
          Create a mutable escaper from an existing escaper, which may already be immutable.
 void makeImmutable()
          Call this before attempting to escape strings; after this, defineEscape may not be called again.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlEscaper

public static StringEscaper xmlEscaper

xmlNumericEscaper

public static StringEscaper xmlNumericEscaper

htmlEscaper

public static StringEscaper htmlEscaper

urlArgEscaper

public static StringEscaper urlArgEscaper

urlEscaper

public static StringEscaper urlEscaper
Constructor Detail

StringEscaper

public StringEscaper()
Identity transform

Method Detail

defineEscape

public void defineEscape(char from,
                         String to)
Map character "from" to escape sequence "to"


makeImmutable

public void makeImmutable()
Call this before attempting to escape strings; after this, defineEscape may not be called again.


escapeString

public String escapeString(String s)
Apply an immutable transformation to the given string.


appendEscapedString

public void appendEscapedString(String s,
                                StringBuffer sb)
Apply an immutable transformation to the given string, writing the results to a string buffer.


clone

protected Object clone()
Overrides:
clone in class Object

getMutableClone

public StringEscaper getMutableClone()
Create a mutable escaper from an existing escaper, which may already be immutable.


SourceForge.net_Logo