Package org.jsoup.nodes
Class Entities
java.lang.Object
org.jsoup.nodes.Entities
HTML entities, and escape routines. Source: W3C
HTML named character references.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final ThreadLocal<char[]> private static final char[](package private) static final intprivate static final intprivate static final String(package private) static final int(package private) static final intprivate static final ThreadLocal<CharsetEncoder> (package private) static final int(package private) static final int(package private) static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidappendApos(QuietAppendable accum, int options, Entities.EscapeMode escapeMode) private static voidappendEncoded(QuietAppendable accum, Entities.EscapeMode escapeMode, int codePoint) private static voidappendEscaped(int codePoint, QuietAppendable accum, int options, Entities.EscapeMode escapeMode, Entities.CoreCharset coreCharset, CharsetEncoder fallback) private static voidappendNbsp(QuietAppendable accum, Entities.EscapeMode escapeMode) private static booleancanEncode(Entities.CoreCharset charset, char c, CharsetEncoder fallback) static intcodepointsForName(String name, int[] codepoints) private static voiddoEscape(String data, QuietAppendable accum, Entities.EscapeMode mode, Charset charset, int options) private static CharsetEncoderencoderFor(Charset charset) static StringHTML escape an input string, using the default settings (UTF-8, base entities).static Stringescape(String data, Document.OutputSettings out) HTML escape an input string.(package private) static voidescape(QuietAppendable accum, String data, Document.OutputSettings out, int options) private static StringescapeString(String data, Entities.EscapeMode escapeMode, Charset charset) static StringfindPrefix(String input) Finds the longest base named entity that is a prefix of the input.static StringGet the character(s) represented by the named entitystatic booleanisBaseNamedEntity(String name) Check if the input is a known named entity in the base entity set.static booleanisNamedEntity(String name) Check if the input is a known named entityprivate static booleanisValidXmlChar(int codePoint) private static voidload(Entities.EscapeMode e, String pointsData, int size) static StringUn-escape an HTML escaped string.(package private) static StringUnescape the input string.
-
Field Details
-
ForText
static final int ForText- See Also:
-
ForAttribute
static final int ForAttribute- See Also:
-
Normalise
static final int Normalise- See Also:
-
TrimLeading
static final int TrimLeading- See Also:
-
TrimTrailing
static final int TrimTrailing- See Also:
-
empty
private static final int empty- See Also:
-
emptyName
- See Also:
-
codepointRadix
static final int codepointRadix- See Also:
-
codeDelims
private static final char[] codeDelims -
multipoints
-
BaseCount
private static final int BaseCount- See Also:
-
baseSorted
-
charBuf
-
LocalEncoder
-
-
Constructor Details
-
Entities
private Entities()
-
-
Method Details
-
isNamedEntity
Check if the input is a known named entity- Parameters:
name- the possible entity name (e.g. "lt" or "amp")- Returns:
- true if a known named entity
-
isBaseNamedEntity
Check if the input is a known named entity in the base entity set.- Parameters:
name- the possible entity name (e.g. "lt" or "amp")- Returns:
- true if a known named entity in the base set
- See Also:
-
getByName
Get the character(s) represented by the named entity- Parameters:
name- entity (e.g. "lt" or "amp")- Returns:
- the string value of the character(s) represented by this entity, or "" if not defined
-
codepointsForName
-
findPrefix
Finds the longest base named entity that is a prefix of the input. That is, input "notit" would return "not".- Returns:
- longest entity name that is a prefix of the input, or "" if no entity matches
-
escape
HTML escape an input string. That is,<is returned as<. The escaped string is suitable for use both in attributes and in text data.- Parameters:
data- the un-escaped string to escapeout- the output settings to use. This configures the character set escaped against (that is, if a character is supported in the output character set, it doesn't have to be escaped), and also HTML or XML settings.- Returns:
- the escaped string
-
escape
HTML escape an input string, using the default settings (UTF-8, base entities). That is,<is returned as<. The escaped string is suitable for use both in attributes and in text data.- Parameters:
data- the un-escaped string to escape- Returns:
- the escaped string
- See Also:
-
escapeString
-
escape
-
doEscape
private static void doEscape(String data, QuietAppendable accum, Entities.EscapeMode mode, Charset charset, int options) -
appendEscaped
private static void appendEscaped(int codePoint, QuietAppendable accum, int options, Entities.EscapeMode escapeMode, Entities.CoreCharset coreCharset, CharsetEncoder fallback) -
appendNbsp
-
appendApos
-
appendEncoded
private static void appendEncoded(QuietAppendable accum, Entities.EscapeMode escapeMode, int codePoint) -
unescape
Un-escape an HTML escaped string. That is,<is returned as<.- Parameters:
string- the HTML string to un-escape- Returns:
- the unescaped string
-
unescape
Unescape the input string.- Parameters:
string- to un-HTML-escapestrict- if "strict" (that is, requires trailing ';' char, otherwise that's optional)- Returns:
- unescaped string
-
canEncode
-
isValidXmlChar
private static boolean isValidXmlChar(int codePoint) -
encoderFor
-
load
-