public class Escape
extends java.lang.Object
unescape( escape( s ) ) === sholds true, but
escape( unescape( s ) ) =?= sdoes not necessarily hold.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
m_escapable
Defines the set of characters that require escaping.
|
private char |
m_escape
Defines the character used to escape characters.
|
Constructor and Description |
---|
Escape()
Defines the default quoting and escaping rules, escaping the
apostrophe, double quote and backslash.
|
Escape(java.lang.String escapable,
char escape)
Constructs arbitrary escaping rules.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
escape(java.lang.String s)
Transforms a given string by escaping all characters inside the
quotable characters set with the escape character.
|
static void |
main(java.lang.String[] args)
Test program.
|
java.lang.String |
unescape(java.lang.String s)
Transforms a given string by unescaping all characters that
are prefixed with the escape character.
|
private char m_escape
private java.lang.String m_escapable
public Escape()
public Escape(java.lang.String escapable, char escape)
escapable
- is the set of characters that require escapingescape
- is the escape character itself.public java.lang.String escape(java.lang.String s)
s
- is the string to escape.unescape( String )
public java.lang.String unescape(java.lang.String s)
s
- is the string to remove escapes from.unescape( String )
public static void main(java.lang.String[] args)
args
- are command-line arguments