public class Escape extends Object
unescape( escape( s ) ) === sholds true, but
escape( unescape( s ) ) =?= sdoes not necessarily hold.
Modifier and Type | Field and Description |
---|---|
private 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(String escapable,
char escape)
Constructs arbitrary escaping rules.
|
Escape(String escapable,
char escape,
boolean escapeEscape)
Constructs arbitrary escaping rules.
|
Modifier and Type | Method and Description |
---|---|
String |
escape(String s)
Transforms a given string by escaping all characters inside the
quotable characters set with the escape character.
|
static void |
main(String[] args)
Test program.
|
String |
unescape(String s)
Transforms a given string by unescaping all characters that
are prefixed with the escape character.
|
private char m_escape
private String m_escapable
public Escape()
public Escape(String escapable, char escape)
escapable
- is the set of characters that require escapingescape
- is the escape character itself.public Escape(String escapable, char escape, boolean escapeEscape)
escapable
- is the set of characters that require escapingescape
- is the escape character itself.escapeEscape
- boolean indicating whether escape character itself
should be escaped if not present in escapable.public String escape(String s)
s
- is the string to escape.unescape( String )
public String unescape(String s)
s
- is the string to remove escapes from.unescape( String )
public static void main(String[] args)
args
- are command-line arguments