Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class CharEntities

  1. Object
  2. 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.

Methods

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.
public static String decodeXml(String ref, Hashtable userDefinedCharEntities)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.

Inherited methods

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 String
The char entity to convert (Not including the & and ;)
lookupHTMLentities boolean
true to include the basic HTML named char entities (unicode 160-255), false otherwise
userDefinedCharEntities Hashtable
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

public static String decodeXml(String ref, Hashtable userDefinedCharEntities)
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 String
the reference without the & and ;
userDefinedCharEntities Hashtable
names the application added, or null

Returns

the decoded characters, or null when the reference is undefined or invalid