|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttreebolic.provider.xml.fast.Entities
class Entities
Provides HTML and XML entity utilities.
Nested Class Summary | |
---|---|
(package private) static interface |
Entities.EntityMap
|
(package private) static class |
Entities.HashEntityMap
|
(package private) static class |
Entities.MapIntMap
|
Field Summary | |
---|---|
private static java.lang.String[][] |
APOS_ARRAY
|
private static java.lang.String[][] |
BASIC_ARRAY
|
private Entities.EntityMap |
map
|
static Entities |
XML
The set of entities supported by standard XML. |
Constructor Summary | |
---|---|
Entities()
|
Method Summary | |
---|---|
private void |
addEntities(java.lang.String[][] entityArray)
Adds entities to this entity. |
private void |
addEntity(java.lang.String name,
int value)
Add an entity to this entity. |
private java.io.StringWriter |
createStringWriter(java.lang.String str)
Make the StringWriter 10% larger than the source String to avoid growing the writer |
private void |
doUnescape(java.io.Writer writer,
java.lang.String str,
int firstAmp)
Underlying unescape method that allows the optimisation of not starting from the 0 index again. |
private int |
entityValue(java.lang.String name)
Returns the value of the entity identified by the specified name. |
java.lang.String |
unescape(java.lang.String str)
Unescapes the entities in a String . |
void |
unescape(java.io.Writer writer,
java.lang.String str)
Unescapes the escaped entities in the String passed and writes the result to the Writer passed. |
static java.lang.String |
unescapeXml(java.lang.String str)
Unescapes a string containing XML entity escapes to a string containing the actual Unicode characters corresponding to the escapes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String[][] BASIC_ARRAY
private static final java.lang.String[][] APOS_ARRAY
public static final Entities XML
The set of entities supported by standard XML.
private Entities.EntityMap map
Constructor Detail |
---|
Entities()
Method Detail |
---|
private void addEntities(java.lang.String[][] entityArray)
Adds entities to this entity.
entityArray
- array of entities to be addedprivate void addEntity(java.lang.String name, int value)
Add an entity to this entity.
name
- name of the entityvalue
- vale of the entityprivate int entityValue(java.lang.String name)
Returns the value of the entity identified by the specified name.
name
- the name to locate
public java.lang.String unescape(java.lang.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
.private java.io.StringWriter createStringWriter(java.lang.String str)
str
- The source string
public void unescape(java.io.Writer writer, java.lang.String str) throws java.io.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.
java.io.IOException
- when Writer
passed throws the exception from calls to the Writer.write(int)
methods.Writer
private void doUnescape(java.io.Writer writer, java.lang.String str, int firstAmp) throws java.io.IOException
writer
- The Writer
to write the results to; assumed to be non-null.str
- The source String
to unescape; assumed to be non-null.firstAmp
- The int
index of the first ampersand in the source String.
java.io.IOException
- when Writer
passed throws the exception from calls to the Writer.write(int)
methods.public static java.lang.String unescapeXml(java.lang.String str)
Unescapes a string containing XML entity escapes to a string containing the actual Unicode characters corresponding to the escapes.
Supports only the five basic XML entities (gt, lt, quot, amp, apos). Does not support DTDs or external entities.
Note that numerical \\u unicode codes are unescaped to their respective unicode characters. This may change in future releases.
str
- the String
to unescape, may be null
String
, null
if null string input
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |