Package de.pdark.decentxml
Class EntityResolver
java.lang.Object
de.pdark.decentxml.EntityResolver
- Direct Known Subclasses:
DocTypeEntityResolver
,HTMLEntityResolver
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Escape for "invalid input: '&'" (ampersand)static final String
Escape for "'" (single quote or apostrophe)private CharValidator
static final String
Escape for ">" (greater than)static final String
Escape for "invalid input: '<'" (less than)private EntityResolver
static final String
Escape for '"' (double quote) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a new entityvoid
clear()
Remove all definitions from the map except the standard XML entities (<, >, ...)Replace text in a string with entity referencesExpand an entity reference.int
expandNumericEntity
(String entity) Returns the character value of a numeric entity.boolean
Check if an entity is defined.Resolve an entity reference.setCharValidator
(CharValidator charValidator) protected String
void
validateEntity
(String entity)
-
Field Details
-
AMP_ESCAPE
Escape for "invalid input: '&'" (ampersand)- See Also:
-
LT_ESCAPE
Escape for "invalid input: '<'" (less than)- See Also:
-
GT_ESCAPE
Escape for ">" (greater than)- See Also:
-
QUOT_ESCAPE
Escape for '"' (double quote)- See Also:
-
APOS_ESCAPE
Escape for "'" (single quote or apostrophe)- See Also:
-
parent
-
resolveMap
-
charValidator
-
-
Constructor Details
-
EntityResolver
public EntityResolver() -
EntityResolver
-
-
Method Details
-
getParent
-
getCharValidator
-
setCharValidator
-
clear
public void clear()Remove all definitions from the map except the standard XML entities (<, >, ...) -
add
Add a new entity- Parameters:
name
- for example "lt"replacementText
- for example "invalid input: '<'"
-
isDefined
Check if an entity is defined.- Parameters:
name
- The name of an entity ("lt" or "<").- Returns:
- the value of the entity or
null
-
resolve
Resolve an entity reference.This returns the text stored for this entity reference. No recursive expansion takes place.
- Parameters:
name
- The name of an entity ("lt" or "<").- Returns:
- the value of the entity or
null
-
stripName
-
expand
Expand an entity reference. If the reference is unknown, the method willnull
.Valid inputs are entity names or entity references (i.e. it will work with "lt" and "<")
-
encode
Replace text in a string with entity references -
expandNumericEntity
Returns the character value of a numeric entity.NOTE: This method returns a "code point", not a character. One "code point" can map to one or two Java characters!
- Throws:
IllegalArgumentException
- if the numeric entity has the wrong format, or the value is too low or high.
-
validateEntity
-