Package org.eigenbase.xom
Class StringEscaper
- java.lang.Object
-
- org.eigenbase.xom.StringEscaper
-
- All Implemented Interfaces:
java.lang.Cloneable
public class StringEscaper extends java.lang.Object implements java.lang.CloneableStringEscaperis 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
Fields Modifier and Type Field Description static StringEscaperhtmlEscaperstatic StringEscaperurlArgEscaperstatic StringEscaperurlEscaperstatic StringEscaperxmlEscaperstatic StringEscaperxmlNumericEscaper
-
Constructor Summary
Constructors Constructor Description StringEscaper()Identity transform
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendEscapedString(java.lang.String s, java.lang.StringBuffer sb)Apply an immutable transformation to the given string, writing the results to a string buffer.protected java.lang.Objectclone()voiddefineEscape(char from, java.lang.String to)Map character "from" to escape sequence "to"java.lang.StringescapeString(java.lang.String s)Apply an immutable transformation to the given string.StringEscapergetMutableClone()Create a mutable escaper from an existing escaper, which may already be immutable.voidmakeImmutable()Call this before attempting to escape strings; after this, defineEscape may not be called again.
-
-
-
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
-
-
Method Detail
-
defineEscape
public void defineEscape(char from, java.lang.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 java.lang.String escapeString(java.lang.String s)
Apply an immutable transformation to the given string.
-
appendEscapedString
public void appendEscapedString(java.lang.String s, java.lang.StringBuffer sb)Apply an immutable transformation to the given string, writing the results to a string buffer.
-
clone
protected java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
getMutableClone
public StringEscaper getMutableClone()
Create a mutable escaper from an existing escaper, which may already be immutable.
-
-