public class Escaper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static char |
DEFAULT_ESCAPE_CHARACTER
The default escape character.
|
static char[] |
DEFAULT_SPECIAL_CHARACTERS
The default set of special characters to escape.
|
static java.lang.String |
ID
Class identification name with source code version and date.
|
Constructor and Description |
---|
Escaper()
Creates an Escaper with the default set of special characters and
the default escape character.
|
Escaper(char[] special_characters,
char escape_character)
Creates an Escaper with the indicated set of special characters and
the indicated escape character.
|
Modifier and Type | Method and Description |
---|---|
char |
escape_character()
Gets the escape character.
|
void |
escape_character(char escape_character)
Sets the escape character.
|
java.lang.String |
escape(java.lang.String string)
Escapes certain characters in a string.
|
char[] |
special_characters()
Gets the set of special characters.
|
void |
special_characters(char[] special_characters)
Sets the set of special characters.
|
java.lang.String |
unescape(java.lang.String string)
Unescapes characters in a string.
|
public static final java.lang.String ID
public static final char DEFAULT_ESCAPE_CHARACTER
public static final char[] DEFAULT_SPECIAL_CHARACTERS
public Escaper(char[] special_characters, char escape_character)
special_characters
- the set of special characters. The
escape_character will be escaped as well.escape_character
- the character that marks a character as escaped.public Escaper()
public char[] special_characters()
escape_character
will be
escaped as well, whether it appears in this list or not.public void special_characters(char[] special_characters)
escape_character
will be
escaped as well, whether it appears in this list or not.special_characters
- the set of special characters, which need not
include the escape character.public char escape_character()
public void escape_character(char escape_character)
escape_character
will be
escaped, whether it appears in the list of special_characters
or
not.escape_character
- the character used to escape other characters.public java.lang.String escape(java.lang.String string)
special_characters
are escaped by prefacing them with the escape_character
.
If string is null, then null is returned.
string
- the unescaped string.public java.lang.String unescape(java.lang.String string)
special_characters
list and that are preceded by the escape_character
are unescaped; the escaped escape character is also
unescaped. Characters that are not in the list but that are preceded
by the escape character are left untouched.
If string is null, then null is returned.
string
- the escaped string.Copyright \ (C) Arizona Board of Regents on behalf of the \ Planetary Image Research Laboratory, Lunar and \ Planetary Laboratory at the University of Arizona