Class CharEntities
The character entity tables of the XML and HTML parsers, and the lookups over them.
It lives here rather than in com.codename1.ui.html so that XMLParser can
decode entities without linking any UI class: the parser is shared with the
server runtime. com.codename1.ui.html.HTMLUtils delegates to it, so the
lenient HTML behaviour is unchanged.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringConverts a char entity to the matching character, the lenient way the HTML parser always has: the XML names match ignoring case, and a numeric reference is truncated to onechar.static StringDecodes a reference the way XML defines it: the five predefined names, matched exactly, a decimal or hexadecimal character reference to a legal code point (a supplementary one becomes a surrogate pair), or a name inuserDefinedCharEntities.
-
Method Details
-
convert
public static String convert(String charEntity, boolean lookupHTMLentities, Hashtable userDefinedCharEntities) Converts a char entity to the matching character, the lenient way the HTML parser always has: the XML names match ignoring case, and a numeric reference is truncated to one
char.Parameters
-
charEntity: The char entity to convert (Not including the & and ;) -
lookupHTMLentities: true to include the basic HTML named char entities (unicode 160-255), false otherwise -
userDefinedCharEntities: A hashtable containing (String,int) denoting the char entity name and its unicode
Returns
A string containing a single char
Throws
IllegalArgumentException: if the entity is unknown
-
-
decodeXml
Decodes a reference the way XML defines it: the five predefined names, matched exactly, a decimal or hexadecimal character reference to a legal code point (a supplementary one becomes a surrogate pair), or a name in
userDefinedCharEntities. Entities a document declares itself are never consulted, so nothing a document says can be expanded.Parameters
-
ref: the reference without the & and ; -
userDefinedCharEntities: names the application added, or null
Returns
the decoded characters, or null when the reference is undefined or invalid
-
-