public class NumericCharacterReference extends CharacterReference
A numeric character reference can be one of two types:
x
' character after the '#
', (eg ">
").
x
' character after the '#
', (eg ">
").
Static methods to encode and decode strings
and single characters can be found in the CharacterReference
superclass.
NumericCharacterReference
instances are obtained using one of the following methods:
CharacterReference
,
CharacterEntityReference
INVALID_CODE_POINT
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
encode(java.lang.CharSequence unencodedText)
Encodes the specified text, escaping special characters into numeric character references.
|
static java.lang.String |
encodeDecimal(java.lang.CharSequence unencodedText)
Encodes the specified text, escaping special characters into decimal character references.
|
static java.lang.String |
encodeHexadecimal(java.lang.CharSequence unencodedText)
Encodes the specified text, escaping special characters into hexadecimal character references.
|
java.lang.String |
getCharacterReferenceString()
Returns the correct encoded form of this numeric character reference.
|
static java.lang.String |
getCharacterReferenceString(int codePoint)
Returns the numeric character reference encoded form of the specified unicode code point.
|
java.lang.String |
getDebugInfo()
Returns a string representation of this object useful for debugging purposes.
|
boolean |
isDecimal()
Indicates whether this numeric character reference specifies the unicode code point in decimal format.
|
boolean |
isHexadecimal()
Indicates whether this numeric character reference specifies the unicode code point in hexadecimal format.
|
appendCharTo, decode, decode, decodeCollapseWhiteSpace, encode, encode, encodeWithWhiteSpaceFormatting, getChar, getCodePoint, getCodePointFromCharacterReferenceString, getDecimalCharacterReferenceString, getDecimalCharacterReferenceString, getEncodingFilterWriter, getHexadecimalCharacterReferenceString, getHexadecimalCharacterReferenceString, getUnicodeText, getUnicodeText, isTerminated, parse, reencode, requiresEncoding
charAt, compareTo, encloses, encloses, equals, getAllCharacterReferences, getAllElements, getAllElements, getAllElements, getAllElements, getAllElements, getAllElementsByClass, getAllStartTags, getAllStartTags, getAllStartTags, getAllStartTags, getAllStartTags, getAllStartTagsByClass, getAllTags, getAllTags, getBegin, getChildElements, getEnd, getFirstElement, getFirstElement, getFirstElement, getFirstElement, getFirstElementByClass, getFirstStartTag, getFirstStartTag, getFirstStartTag, getFirstStartTag, getFirstStartTag, getFirstStartTagByClass, getFormControls, getFormFields, getMaxDepthIndicator, getNodeIterator, getRenderer, getRowColumnVector, getSource, getStyleURISegments, getTextExtractor, getURIAttributes, hashCode, ignoreWhenParsing, isWhiteSpace, isWhiteSpace, length, parseAttributes, subSequence, toString
public boolean isDecimal()
A numeric character reference in decimal format is referred to in this library as a decimal character reference.
true
if this numeric character reference specifies the unicode code point in decimal format, otherwise false
.isHexadecimal()
public boolean isHexadecimal()
A numeric character reference in hexadecimal format is referred to in this library as a hexadecimal character reference.
true
if this numeric character reference specifies the unicode code point in hexadecimal format, otherwise false
.isDecimal()
public static java.lang.String encode(java.lang.CharSequence unencodedText)
The Config.CurrentCharacterReferenceEncodingBehaviour
setting determines which characters are encoded.
This method encodes all character references in decimal format, and is exactly the same as calling
encodeDecimal(CharSequence)
.
To encode text using both character entity references and numeric character references, use the
CharacterReference.encode(CharSequence)
method instead.
To encode text using hexadecimal character references only,
use the encodeHexadecimal(CharSequence)
method instead.
unencodedText
- the text to encode.CharacterReference.decode(CharSequence)
public static java.lang.String encodeDecimal(java.lang.CharSequence unencodedText)
The Config.CurrentCharacterReferenceEncodingBehaviour
setting determines which characters are encoded.
To encode text using both character entity references and numeric character references, use the
CharacterReference.encode(CharSequence)
method instead.
To encode text using hexadecimal character references only,
use the encodeHexadecimal(CharSequence)
method instead.
unencodedText
- the text to encode.CharacterReference.decode(CharSequence)
public static java.lang.String encodeHexadecimal(java.lang.CharSequence unencodedText)
The Config.CurrentCharacterReferenceEncodingBehaviour
setting determines which characters are encoded.
To encode text using both character entity references and numeric character references, use the
CharacterReference.encode(CharSequence)
method instead.
To encode text using decimal character references only,
use the encodeDecimal(CharSequence)
method instead.
unencodedText
- the text to encode.CharacterReference.decode(CharSequence)
public java.lang.String getCharacterReferenceString()
The returned string uses the same radix as the original character reference in the source document,
i.e. decimal format if isDecimal()
is true
, and hexadecimal format if isHexadecimal()
is true
.
Note that the returned string is not necessarily the same as the original source text used to create this object.
This library recognises certain invalid forms of character references,
as detailed in the decode(CharSequence)
method.
To retrieve the original source text, use the toString()
method instead.
CharacterReference.parse(">").getCharacterReferenceString()
returns ">
"getCharacterReferenceString
in class CharacterReference
CharacterReference.getCharacterReferenceString(int codePoint)
public static java.lang.String getCharacterReferenceString(int codePoint)
This method returns the character reference in decimal format, and is exactly the same as calling
CharacterReference.getDecimalCharacterReferenceString(int codePoint)
.
To get either the character entity reference or numeric character reference, use the
CharacterReference.getCharacterReferenceString(int codePoint)
method instead.
To get the character reference in hexadecimal format, use the CharacterReference.getHexadecimalCharacterReferenceString(int codePoint)
method instead.
NumericCharacterReference.getCharacterReferenceString(62)
returns ">
"NumericCharacterReference.getCharacterReferenceString('>')
returns ">
"CharacterReference.getCharacterReferenceString(int codePoint)
public java.lang.String getDebugInfo()
Segment
getDebugInfo
in class Segment