public static class StringEscapeUtils.Entities extends Object
Provides HTML and XML entity utilities.
| Modifier and Type | Field and Description |
|---|---|
static StringEscapeUtils.Entities |
HTML32
The set of entities supported by HTML 3.2.
|
static StringEscapeUtils.Entities |
HTML40
The set of entities supported by HTML 4.0.
|
static StringEscapeUtils.Entities |
XML
The set of entities supported by standard XML.
|
| Constructor and Description |
|---|
StringEscapeUtils.Entities() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEntities(String[][] entityArray)
Adds entities to this entity.
|
void |
addEntity(String name,
int value)
Add an entity to this entity.
|
String |
entityName(int value)
Returns the name of the entity identified by the specified value.
|
int |
entityValue(String name)
Returns the value of the entity identified by the specified name.
|
String |
escape(String str)
Escapes the characters in a
String. |
void |
escape(Writer writer,
String str)
Escapes the characters in the
String passed and writes the result to the Writer
passed. |
String |
generateDocType(String docTypeName) |
String |
unescape(String str)
Unescapes the entities in a
String. |
void |
unescape(Writer writer,
String str)
Unescapes the escaped entities in the
String passed and writes the result to the
Writer passed. |
public static final StringEscapeUtils.Entities XML
The set of entities supported by standard XML.
public static final StringEscapeUtils.Entities HTML32
The set of entities supported by HTML 3.2.
public static final StringEscapeUtils.Entities HTML40
The set of entities supported by HTML 4.0.
public void addEntities(String[][] entityArray)
Adds entities to this entity.
entityArray - array of entities to be addedpublic void addEntity(String name, int value)
Add an entity to this entity.
name - name of the entityvalue - vale of the entitypublic String entityName(int value)
Returns the name of the entity identified by the specified value.
value - the value to locatepublic int entityValue(String name)
Returns the value of the entity identified by the specified name.
name - the name to locatepublic String escape(String str)
Escapes the characters in a String.
For example, if you have called addEntity("foo", 0xA1), escape("¡") will return "&foo;"
str - The String to escape.String.public void escape(Writer writer, String str) throws IOException
Escapes the characters in the String passed and writes the result to the Writer
passed.
writer - The Writer to write the results of the escaping to. Assumed to be a non-null
value.str - The String to escape. Assumed to be a non-null value.IOException - when Writer passed throws the exception from calls to the
Writer.write(int) methods.escape(String),
Writerpublic String unescape(String str)
Unescapes the entities in a String.
For example, if you have called addEntity("foo", 0xA1), unescape("&foo;") will return "¡"
str - The String to escape.String.public void unescape(Writer writer, String str) throws IOException
Unescapes the escaped entities in the String passed and writes the result to the
Writer passed.
writer - The Writer to write the results to; assumed to be non-null.str - The source String to unescape; assumed to be non-null.IOException - when Writer passed throws the exception from calls to the
Writer.write(int) methods.escape(String),
WriterCopyright © 2015. All Rights Reserved.