public class HtmlTools
extends java.lang.Object
HtmlTools class defines methods to HTML handling.| Modifier and Type | Field and Description |
|---|---|
private static javax.swing.text.html.HTML.Tag[] |
ALL_TAGS |
private static int |
ASCII |
private static char |
LOW_SURROGATE |
private static char |
LUNATE_SIGMA |
private static int |
MAX_CODE_POINT |
private static char |
MAX_HIGH_SURROGATE |
private static int |
MIN_CODE_POINT |
private static char |
MIN_HIGH_SURROGATE |
private static int |
MIN_SUPPLEMENTARY_CODE_POINT |
private static char |
NON_PRIVATE_USE_HIGH_SURROGATE |
private static java.util.Map<java.lang.String,javax.swing.text.html.HTML.Tag> |
TAG_MAP |
| Modifier | Constructor and Description |
|---|---|
private |
HtmlTools() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
encodeId(java.lang.String id)
Construct a valid id.
|
static java.lang.String |
encodeURL(java.lang.String url)
Encode an url
|
static java.lang.String |
escapeHTML(java.lang.String text)
Escape special HTML characters in a String in
xml mode. |
static java.lang.String |
escapeHTML(java.lang.String text,
boolean xmlMode)
Escape special HTML characters in a String.
|
static javax.swing.text.html.HTML.Tag |
getHtmlTag(java.lang.String tagName)
Returns a tag for a defined HTML tag name.
|
private static boolean |
isHighSurrogate(char ch) |
static boolean |
isId(java.lang.String text)
Determines if the specified text is a valid id according to the rules
laid out in
encodeId(String). |
private static boolean |
isSupplementaryCodePoint(int codePoint) |
private static boolean |
isValidCodePoint(int codePoint) |
static char[] |
toChars(int codePoint)
Converts the given code point to an equivalent character array.
|
private static int |
toCodePoint(char high,
char low) |
static java.lang.String |
unescapeHTML(java.lang.String text)
Unescapes HTML entities in a string in non xml mode.
|
static java.lang.String |
unescapeHTML(java.lang.String text,
boolean xmlMode)
Unescapes HTML entities in a string.
|
private static final javax.swing.text.html.HTML.Tag[] ALL_TAGS
private static final java.util.Map<java.lang.String,javax.swing.text.html.HTML.Tag> TAG_MAP
private static final int ASCII
private static final char LUNATE_SIGMA
private static final char NON_PRIVATE_USE_HIGH_SURROGATE
private static final char LOW_SURROGATE
private static final char MIN_HIGH_SURROGATE
private static final char MAX_HIGH_SURROGATE
private static final int MIN_CODE_POINT
private static final int MAX_CODE_POINT
private static final int MIN_SUPPLEMENTARY_CODE_POINT
public static javax.swing.text.html.HTML.Tag getHtmlTag(java.lang.String tagName)
HtmlMarkup.
If the given name does not represent one of the defined tags, then
null will be returned.tagName - the String name requested.tagName,
or null if not found.public static java.lang.String escapeHTML(java.lang.String text)
xml mode.
Note: this method doesn't escape non-ascii characters by numeric characters references.text - the String to escape, may be null.escapeHTML(String,boolean)public static java.lang.String escapeHTML(java.lang.String text,
boolean xmlMode)
< becomesIf<> becomes>& becomes&" becomes"' becomes'if xmlMode = true
xmlMode is true, every other character than the above remains unchanged,
if xmlMode is false, non-ascii characters get replaced by their hex code.
Note: all characters are encoded, i.e.:
ř = ř 𝟭 = 𝟭
text - The String to escape, may be null.xmlMode - true to replace also ' to &apos, false to replace non-ascii
characters by numeric characters references.public static java.lang.String unescapeHTML(java.lang.String text)
text - the String to unescape, may be null.String, null if null string input.unescapeHTML(String, boolean)public static java.lang.String unescapeHTML(java.lang.String text,
boolean xmlMode)
Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes. Supports HTML 4.0 entities.
For example, the string "<Français>" will become "<Français>".
Note: all unicode entities are decoded, i.e.:ř = ř 𝟭 = 𝟭
text - the String to unescape, may be null.xmlMode - set to true to replace &apos by '.String, null if null string input.public static java.lang.String encodeURL(java.lang.String url)
url - the String to encode, may be nullpublic static java.lang.String encodeId(java.lang.String id)
Note: this method is identical to
DoxiaUtils.encodeId( id, true),
the rules to encode an id are laid out there.
id - The id to be encoded.DoxiaUtils.encodeId(java.lang.String,boolean)public static boolean isId(java.lang.String text)
encodeId(String).text - The text to be tested.true if the text is a valid id, otherwise false.encodeId(String).private static int toCodePoint(char high,
char low)
private static boolean isHighSurrogate(char ch)
private static boolean isValidCodePoint(int codePoint)
private static boolean isSupplementaryCodePoint(int codePoint)
public static char[] toChars(int codePoint)
codePoint - the code point to convert.