| Modifier and Type | Field and Description |
|---|---|
private static java.util.Map<java.lang.Character,java.lang.String> |
characterToEntityMap |
private static Trie<java.lang.Character> |
entityToCharacterTrie |
private static char |
REPLACEMENT_CHAR |
private static java.lang.String |
REPLACEMENT_HEX |
private static java.lang.String |
REPLACEMENT_STR |
| Constructor and Description |
|---|
HTMLEntityCodec() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Character |
decodeCharacter(PushbackString input)
Returns the decoded version of the next character from the input string and advances the
current character in the PushbackString.
|
java.lang.String |
encodeCharacter(char[] immune,
java.lang.Character c)
Default implementation that should be overridden in specific codecs.
|
private java.lang.Character |
getNamedEntity(PushbackString input)
Returns the decoded version of the character starting at index, or
null if no decoding is possible.
|
private java.lang.Character |
getNumericEntity(PushbackString input)
getNumericEntry checks input to see if it is a numeric entity
|
private static java.util.Map<java.lang.Character,java.lang.String> |
mkCharacterToEntityMap()
Build a unmodifiable Map from entity Character to Name.
|
private static Trie<java.lang.Character> |
mkEntityToCharacterTrie()
Build a unmodifiable Trie from entitiy Name to Character
|
private java.lang.Character |
parseHex(PushbackString input)
Parse a hex encoded entity
|
private java.lang.Character |
parseNumber(PushbackString input)
Parse a decimal number, such as those from JavaScript's String.fromCharCode(value)
|
containsCharacter, decode, encode, getHexForNonAlphanumeric, toHex, toOctalprivate static final char REPLACEMENT_CHAR
private static final java.lang.String REPLACEMENT_HEX
private static final java.lang.String REPLACEMENT_STR
private static final java.util.Map<java.lang.Character,java.lang.String> characterToEntityMap
private static final Trie<java.lang.Character> entityToCharacterTrie
public java.lang.String encodeCharacter(char[] immune,
java.lang.Character c)
encodeCharacter in class Codecimmune - c - the Character to encodepublic java.lang.Character decodeCharacter(PushbackString input)
decodeCharacter in class Codecinput - the Character to decodeprivate java.lang.Character getNumericEntity(PushbackString input)
input - The input to test for being a numeric entityprivate java.lang.Character parseNumber(PushbackString input)
input - decimal encoded string, such as 65java.lang.NumberFormatExceptionprivate java.lang.Character parseHex(PushbackString input)
input - Hex encoded input (such as 437ae;)java.lang.NumberFormatExceptionprivate java.lang.Character getNamedEntity(PushbackString input)
input - A string containing a named entity like "private static java.util.Map<java.lang.Character,java.lang.String> mkCharacterToEntityMap()
private static Trie<java.lang.Character> mkEntityToCharacterTrie()