Package org.apache.maven.doxia.util
Class HtmlTools
java.lang.Object
org.apache.maven.doxia.util.HtmlTools
The
HtmlTools class defines methods to HTML handling.- Since:
- 1.0
- Author:
- Vincent Siveton
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringEncode an urlstatic StringescapeHTML(String text) Escape special HTML characters in a String inxmlmode.static StringescapeHTML(String text, boolean xmlMode) Escape special HTML characters in a String.static HTML.TaggetHtmlTag(String tagName) Returns a tag for a defined HTML tag name.static char[]toChars(int codePoint) Converts the given code point to an equivalent character array.static StringunescapeHTML(String text) Unescapes HTML entities in a string in non xml mode.static StringunescapeHTML(String text, boolean xmlMode) Unescapes HTML entities in a string.
-
Method Details
-
getHtmlTag
Returns a tag for a defined HTML tag name. This is one of the tags defined inHtmlMarkup. If the given name does not represent one of the defined tags, thennullwill be returned.- Parameters:
tagName- theStringname requested.- Returns:
- a tag constant corresponding to the
tagName, ornullif not found. - Since:
- 1.1
- See Also:
-
escapeHTML
Escape special HTML characters in a String inxmlmode. Note: this method doesn't escape non-ascii characters by numeric characters references.- Parameters:
text- the String to escape, may be null.- Returns:
- The escaped text or the empty string if text == null.
- See Also:
-
escapeHTML
Escape special HTML characters in a String.< becomes
If<> becomes>& becomes&" becomes"' becomes'if xmlMode = truexmlModeis true, every other character than the above remains unchanged, ifxmlModeis false, non-ascii characters get replaced by their hex code. Note: all characters are encoded, i.e.:ř = ř 𝟭 = 𝟭
- Parameters:
text- The String to escape, may be null.xmlMode-trueto replace also ' to &apos,falseto replace non-ascii characters by numeric characters references.- Returns:
- The escaped text or the empty string if text == null.
- Since:
- 1.1
- See Also:
-
unescapeHTML
Unescapes HTML entities in a string in non xml mode.- Parameters:
text- theStringto unescape, may be null.- Returns:
- a new unescaped
String,nullif null string input. - Since:
- 1.1.1.
- See Also:
-
unescapeHTML
Unescapes HTML entities in a string.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.:ř = ř 𝟭 = 𝟭
- Parameters:
text- theStringto unescape, may be null.xmlMode- set totrueto replace &apos by '.- Returns:
- a new unescaped
String,nullif null string input. - Since:
- 1.1.1.
-
encodeURL
Encode an url- Parameters:
url- the String to encode, may be null- Returns:
- the text encoded, null if null String input
-
toChars
public static char[] toChars(int codePoint) Converts the given code point to an equivalent character array.- Parameters:
codePoint- the code point to convert.- Returns:
- If codePoint is a supplementary code point, returns a character array of length 2, otherwise a character array of length 1 containing only the original int as a char.
-