public class HtmlUtil
extends Object
Constructor and Description |
---|
HtmlUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
buildData(Map<String,Object> data) |
static String |
escape(String text)
Escapes the text so that it is safe to use in an HTML context.
|
static String |
escapeAttribute(String attribute)
Escapes the attribute value so that it is safe to use as an attribute
value.
|
static String |
escapeCSS(String css)
Escapes the CSS value so that it is safe to use in a CSS context.
|
static String |
escapeHREF(String href)
Escapes the HREF attribute so that it is safe to use as an HREF
attribute.
|
static String |
escapeJS(String js)
Escapes the JavaScript value so that it is safe to use in a JavaScript
context.
|
static String |
escapeJSLink(String link) |
static String |
escapeURL(String url)
Escapes the URL value so that it is safe to use as a URL.
|
static String |
escapeXPath(String xPath) |
static String |
escapeXPathAttribute(String xPathAttribute) |
static String |
fromInputSafe(String text) |
static String |
getAUICompatibleId(String html) |
static Html |
getHtml() |
static String |
replaceNewLine(String html)
Replaces all new lines or carriage returns with the
HTML tag. |
void |
setHtml(Html html) |
static String |
stripBetween(String text,
String tag)
Strips all content delimited by the tag out of the text.
|
static String |
stripComments(String text)
Strips all XML comments out of the text.
|
static String |
stripHtml(String text) |
static String |
toInputSafe(String text)
Encodes the text so that it's safe to use as an HTML input field value.
|
static String |
unescape(String text) |
static String |
unescapeCDATA(String text) |
static String |
wordBreak(String text,
int columns) |
public static String buildData(Map<String,Object> data)
public static String escape(String text)
text
- the text to escapenull
if the text is
null
public static String escapeAttribute(String attribute)
attribute
- the attribute to escapenull
if the
attribute value is null
public static String escapeCSS(String css)
css
- the CSS value to escapenull
if the CSS value is
null
public static String escapeHREF(String href)
href
- the HREF attribute to escapenull
if the HREF
attribute is null
public static String escapeJS(String js)
js
- the JavaScript value to escapenull
if the
JavaScript value is null
public static String escapeJSLink(String link)
public static String escapeURL(String url)
url
- the URL value to escapenull
if the URL value is
null
public static String escapeXPath(String xPath)
public static String escapeXPathAttribute(String xPathAttribute)
public static String fromInputSafe(String text)
public static String getAUICompatibleId(String html)
public static Html getHtml()
public static String replaceNewLine(String html)
HTML tag.html
- the textnull
if the HTML text is
null
public static String stripBetween(String text, String tag)
If the tag appears multiple times, all occurrences (including the tag) are stripped. The tag may have attributes. In order for this method to recognize the tag, it must consist of a separate opening and closing tag. Self-closing tags remain in the result.
text
- the texttag
- the tag used for delimiting, which should only be the tag's
name (e.g. no <)null
if the text is null
public static String stripComments(String text)
text
- the textnull
if the text is null
public static String stripHtml(String text)
public static String toInputSafe(String text)
For example, the &
character is replaced by
&
.
text
- the textnull
if the text is null
public static String unescape(String text)
public static String unescapeCDATA(String text)
public static String wordBreak(String text, int columns)
public void setHtml(Html html)