public class HtmlImpl
extends Object
implements com.liferay.portal.kernel.util.Html
| Constructor and Description |
|---|
HtmlImpl() |
| Modifier and Type | Method and Description |
|---|---|
String |
buildData(Map<String,Object> data)
Generates a string with the data-* attributes generated from the keys and
values of a map.
|
String |
escape(String text)
Escapes the text so that it is safe to use in an HTML context.
|
String |
escapeAttribute(String attribute)
Escapes the attribute value so that it is safe to use within a quoted
attribute.
|
String |
escapeCSS(String css)
Escapes the CSS value so that it is safe to use in a CSS context.
|
String |
escapeHREF(String href)
Escapes the HREF attribute so that it is safe to use as an HREF
attribute.
|
String |
escapeJS(String js)
Escapes the JavaScript value so that it is safe to use in a JavaScript
context.
|
String |
escapeJSLink(String link) |
String |
escapeURL(String url)
Escapes the URL value so that it is safe to use as a URL.
|
String |
escapeXPath(String xPath) |
String |
escapeXPathAttribute(String xPathAttribute) |
String |
fromInputSafe(String text) |
String |
getAUICompatibleId(String text) |
protected boolean |
isTag(char[] tag,
String text,
int pos) |
String |
replaceNewLine(String html)
Replaces all new lines or carriage returns with the
HTML tag. |
String |
stripBetween(String text,
String tag)
Strips all content delimited by the tag out of the text.
|
String |
stripComments(String text)
Strips all XML comments out of the text.
|
String |
stripHtml(String text) |
protected int |
stripTag(char[] tag,
String text,
int pos) |
String |
toInputSafe(String text)
Encodes the text so that it's safe to use as an HTML input field value.
|
String |
unescape(String text) |
String |
unescapeCDATA(String text) |
String |
wordBreak(String text,
int columns) |
public String buildData(Map<String,Object> data)
{key1=value1;key2=value2} is returned as the string
data-key1=value1 data-key2=value2.buildData in interface com.liferay.portal.kernel.util.Htmldata - the map of values to convert to data-* attributesnull if the
map is nullpublic String escape(String text)
escape in interface com.liferay.portal.kernel.util.Htmltext - the text to escapenull if the text is
nullpublic String escapeAttribute(String attribute)
escapeAttribute in interface com.liferay.portal.kernel.util.Htmlattribute - the attribute to escapenull if the
attribute value is nullpublic String escapeCSS(String css)
escapeCSS in interface com.liferay.portal.kernel.util.Htmlcss - the CSS value to escapenull if the CSS value is
nullpublic String escapeHREF(String href)
escapeHREF in interface com.liferay.portal.kernel.util.Htmlhref - the HREF attribute to escapenull if the HREF
attribute is nullpublic String escapeJS(String js)
escapeJS in interface com.liferay.portal.kernel.util.Htmljs - the JavaScript value to escapenull if the
JavaScript value is nullpublic String escapeJSLink(String link)
escapeJSLink in interface com.liferay.portal.kernel.util.Htmlpublic String escapeURL(String url)
escapeURL in interface com.liferay.portal.kernel.util.Htmlurl - the URL value to escapenull if the URL value is
nullpublic String escapeXPath(String xPath)
escapeXPath in interface com.liferay.portal.kernel.util.Htmlpublic String escapeXPathAttribute(String xPathAttribute)
escapeXPathAttribute in interface com.liferay.portal.kernel.util.Htmlpublic String fromInputSafe(String text)
fromInputSafe in interface com.liferay.portal.kernel.util.Htmlpublic String getAUICompatibleId(String text)
getAUICompatibleId in interface com.liferay.portal.kernel.util.Htmlpublic String replaceNewLine(String html)
HTML tag.replaceNewLine in interface com.liferay.portal.kernel.util.Htmlhtml - the textnull if the text is
nullpublic 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.
stripBetween in interface com.liferay.portal.kernel.util.Htmltext - the texttag - the tag used for delimiting, which should only be the tag's
name (e.g. no <)null if the text is nullpublic String stripComments(String text)
stripComments in interface com.liferay.portal.kernel.util.Htmltext - the textnull
if the text is nullpublic String stripHtml(String text)
stripHtml in interface com.liferay.portal.kernel.util.Htmlpublic String toInputSafe(String text)
For example, the & character is replaced by
&.
toInputSafe in interface com.liferay.portal.kernel.util.Htmltext - the textnull if the text is nullpublic String unescape(String text)
unescape in interface com.liferay.portal.kernel.util.Htmlpublic String unescapeCDATA(String text)
unescapeCDATA in interface com.liferay.portal.kernel.util.Htmlpublic String wordBreak(String text,
int columns)
wordBreak in interface com.liferay.portal.kernel.util.Htmlprotected boolean isTag(char[] tag,
String text,
int pos)
protected int stripTag(char[] tag,
String text,
int pos)