Top Description Inners Fields Constructors Methods
org.apache.commons.text.translate

public Class NumericEntityUnescaper

extends CharSequenceTranslator
Class Inheritance
Imports
java.io.IOException, .Writer, java.util.Arrays, .Collections, .EnumSet, org.apache.commons.lang3.ArrayUtils

Translates XML numeric entities of the form &#[xX]?\d+;? to the specific code point. Note that the semicolon is optional.
Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
NumericEntityUnescaper.OPTION

Enumerates NumericEntityUnescaper options for unescaping.

Field Summary

Modifier and TypeField and Description
private static final EnumSet<NumericEntityUnescaper.OPTION>
DEFAULT_OPTIONS

Default options.

private final EnumSet<NumericEntityUnescaper.OPTION>
options

EnumSet of OPTIONS, given from the constructor, read-only.

Inherited from org.apache.commons.text.translate.CharSequenceTranslator:
HEX_DIGITS

Constructor Summary

AccessConstructor and Description
public
NumericEntityUnescaper(final NumericEntityUnescaper.OPTION...
to apply to this unescaper
options
)

Creates a UnicodeUnescaper.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

whether the option is set.
isSet
(final NumericEntityUnescaper.OPTION
to check state of.
option
)

Tests whether the passed in option is currently set.

public int
translate(final CharSequence input, final int index, final Writer writer)

Implements abstract org.apache.commons.text.translate.CharSequenceTranslator.translate.

Translate a set of code points, represented by an int index into a CharSequence, into another set of code points.

Inherited from org.apache.commons.text.translate.CharSequenceTranslator:
hextranslatetranslatewith

Field Detail

DEFAULT_OPTIONSback to summary
private static final EnumSet<NumericEntityUnescaper.OPTION> DEFAULT_OPTIONS

Default options.

optionsback to summary
private final EnumSet<NumericEntityUnescaper.OPTION> options

EnumSet of OPTIONS, given from the constructor, read-only.

Constructor Detail

NumericEntityUnescaperback to summary
public NumericEntityUnescaper(final NumericEntityUnescaper.OPTION... options)

Creates a UnicodeUnescaper. The constructor takes a list of options, only one type of which is currently available (whether to allow, error or ignore the semicolon on the end of a numeric entity to being missing).

For example, to support numeric entities without a ';':

new NumericEntityUnescaper(NumericEntityUnescaper.OPTION.semiColonOptional)

and to throw an IllegalArgumentException when they're missing:

new NumericEntityUnescaper(NumericEntityUnescaper.OPTION.errorIfNoSemiColon)

Note that the default behavior is to ignore them.

Parameters
options:NumericEntityUnescaper.OPTION[]

to apply to this unescaper

Method Detail

isSetback to summary
public boolean isSet(final NumericEntityUnescaper.OPTION option)

Tests whether the passed in option is currently set.

Parameters
option:NumericEntityUnescaper.OPTION

to check state of.

Returns:boolean

whether the option is set.

translateback to summary
public int translate(final CharSequence input, final int index, final Writer writer) throws IOException

Implements abstract org.apache.commons.text.translate.CharSequenceTranslator.translate.

Doc from org.apache.commons.text.translate.CharSequenceTranslator.translate.

Translate a set of code points, represented by an int index into a CharSequence, into another set of code points. The number of code points consumed must be returned, and the only IOExceptions thrown must be from interacting with the Writer so that the top level API may reliably ignore StringWriter IOExceptions.

Annotations
@Override
Exceptions
IOException:
if and only if the Writer produces an IOException.
org.apache.commons.text.translate back to summary

public final Enum NumericEntityUnescaper.OPTION

extends Enum<NumericEntityUnescaper.OPTION>
Class Inheritance

Enumerates NumericEntityUnescaper options for unescaping.

Field Summary

Modifier and TypeField and Description
public static final NumericEntityUnescaper.OPTION
errorIfNoSemiColon

Throws an exception if a semicolon is missing.

public static final NumericEntityUnescaper.OPTION
semiColonOptional

Does not require a semicolon.

public static final NumericEntityUnescaper.OPTION
semiColonRequired

Requires a semicolon.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static NumericEntityUnescaper.OPTION
public static NumericEntityUnescaper.OPTION[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

errorIfNoSemiColonback to summary
public static final NumericEntityUnescaper.OPTION errorIfNoSemiColon

Throws an exception if a semicolon is missing.

semiColonOptionalback to summary
public static final NumericEntityUnescaper.OPTION semiColonOptional

Does not require a semicolon.

semiColonRequiredback to summary
public static final NumericEntityUnescaper.OPTION semiColonRequired

Requires a semicolon.

Constructor Detail

OPTIONback to summary
private OPTION()

Method Detail

valueOfback to summary
public static NumericEntityUnescaper.OPTION valueOf(String name)
valuesback to summary
public static NumericEntityUnescaper.OPTION[] values()