public class EntityResolver extends Object
Modifier and Type | Field and Description |
---|---|
static String |
AMP_ESCAPE
Escape for "&" (ampersand)
|
static String |
APOS_ESCAPE
Escape for "'" (single quote or apostrophe)
|
static String |
GT_ESCAPE
Escape for ">" (greater than)
|
static String |
LT_ESCAPE
Escape for "<" (less than)
|
static String |
QUOT_ESCAPE
Escape for '"' (double quote)
|
protected Map<String,String> |
resolveMap |
Constructor and Description |
---|
EntityResolver() |
EntityResolver(EntityResolver parent) |
Modifier and Type | Method and Description |
---|---|
void |
add(String name,
String replacementText)
Add a new entity
|
void |
clear()
Remove all definitions from the map except the standard XML
entities (<, >, ...)
|
String |
encode(String input)
Replace text in a string with entity references
|
String |
expand(String entity)
Expand an entity reference.
|
int |
expandNumericEntity(String entity)
Returns the character value of a numeric entity.
|
CharValidator |
getCharValidator() |
EntityResolver |
getParent() |
boolean |
isDefined(String name)
Check if an entity is defined.
|
String |
resolve(String name)
Resolve an entity reference.
|
EntityResolver |
setCharValidator(CharValidator charValidator) |
protected String |
stripName(String name) |
void |
validateEntity(String entity) |
public static final String AMP_ESCAPE
public static final String LT_ESCAPE
public static final String GT_ESCAPE
public static final String QUOT_ESCAPE
public static final String APOS_ESCAPE
public EntityResolver()
public EntityResolver(EntityResolver parent)
public EntityResolver getParent()
public CharValidator getCharValidator()
public EntityResolver setCharValidator(CharValidator charValidator)
public void clear()
public void add(String name, String replacementText)
name
- for example "lt"replacementText
- for example "<"public boolean isDefined(String name)
name
- The name of an entity ("lt" or "<").null
public String resolve(String name)
This returns the text stored for this entity reference. No recursive expansion takes place.
name
- The name of an entity ("lt" or "<").null
public String expand(String entity)
null
.
Valid inputs are entity names or entity references (i.e. it will work with "lt" and "<")
public int expandNumericEntity(String entity)
NOTE: This method returns a "code point", not a character. One "code point" can map to one or two Java characters!
IllegalArgumentException
- if the numeric entity has the wrong format, or the value is too low or high.public void validateEntity(String entity)
Copyright © 2008–2021. All rights reserved.