本文整理汇总了Java中org.apache.commons.lang.StringEscapeUtils.unescapeHtml方法的典型用法代码示例。如果您正苦于以下问题:Java StringEscapeUtils.unescapeHtml方法的具体用法?Java StringEscapeUtils.unescapeHtml怎么用?Java StringEscapeUtils.unescapeHtml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.StringEscapeUtils
的用法示例。
在下文中一共展示了StringEscapeUtils.unescapeHtml方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPlaintextFromEditor
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Returns plain text from the editor.
*
* @param editor
* the editor from which to take the text.
* @param onlySelected
* if {@code true} will only return the selected text
* @return the text of the editor converted to plain text
* @throws BadLocationException
* @throws IOException
*/
public static String getPlaintextFromEditor(final JEditorPane editor, final boolean onlySelected) throws IOException,
BadLocationException {
if (editor == null) {
throw new IllegalArgumentException("editor must not be null!");
}
HTMLDocument document = (HTMLDocument) editor.getDocument();
StringWriter writer = new StringWriter();
int start = 0;
int length = document.getLength();
if (onlySelected) {
start = editor.getSelectionStart();
length = editor.getSelectionEnd() - start;
}
editor.getEditorKit().write(writer, document, start, length);
String text = writer.toString();
text = AnnotationDrawUtils.removeStyleFromComment(text);
// switch <br> and <br/> to actual newline (current system)
text = text.replaceAll("<br.*?>", System.lineSeparator());
// kill all other html tags
text = text.replaceAll("\\<.*?>", "");
text = StringEscapeUtils.unescapeHtml(text);
return text;
}
示例2: applyValueDefaultModifications
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
*
* @param fieldValue
* @return
*/
public static String applyValueDefaultModifications(String fieldValue) {
String ret = fieldValue;
if (StringUtils.isNotEmpty(ret)) {
// Remove any prior HTML escaping, otherwise strings like '&amp;' might occur
ret = StringEscapeUtils.unescapeHtml(ret);
}
return ret;
}
示例3: applyChanges
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Apply configuratio changes after admin has approved them.
*/
private void applyChanges(PrintWriter out, Reconfigurable reconf,
HttpServletRequest req) throws ReconfigurationException {
Configuration oldConf = reconf.getConf();
Configuration newConf = new Configuration();
Enumeration<String> params = getParams(req);
synchronized(oldConf) {
while (params.hasMoreElements()) {
String rawParam = params.nextElement();
String param = StringEscapeUtils.unescapeHtml(rawParam);
String value =
StringEscapeUtils.unescapeHtml(req.getParameter(rawParam));
if (value != null) {
if (value.equals(newConf.getRaw(param)) || value.equals("default") ||
value.equals("null") || value.isEmpty()) {
if ((value.equals("default") || value.equals("null") ||
value.isEmpty()) &&
oldConf.getRaw(param) != null) {
out.println("<p>Changed \"" +
StringEscapeUtils.escapeHtml(param) + "\" from \"" +
StringEscapeUtils.escapeHtml(oldConf.getRaw(param)) +
"\" to default</p>");
reconf.reconfigureProperty(param, null);
} else if (!value.equals("default") && !value.equals("null") &&
!value.isEmpty() &&
(oldConf.getRaw(param) == null ||
!oldConf.getRaw(param).equals(value))) {
// change from default or value to different value
if (oldConf.getRaw(param) == null) {
out.println("<p>Changed \"" +
StringEscapeUtils.escapeHtml(param) +
"\" from default to \"" +
StringEscapeUtils.escapeHtml(value) + "\"</p>");
} else {
out.println("<p>Changed \"" +
StringEscapeUtils.escapeHtml(param) + "\" from \"" +
StringEscapeUtils.escapeHtml(oldConf.
getRaw(param)) +
"\" to \"" +
StringEscapeUtils.escapeHtml(value) + "\"</p>");
}
reconf.reconfigureProperty(param, value);
} else {
LOG.info("property " + param + " unchanged");
}
} else {
// parameter value != newConf value
out.println("<p>\"" + StringEscapeUtils.escapeHtml(param) +
"\" not changed because value has changed from \"" +
StringEscapeUtils.escapeHtml(value) + "\" to \"" +
StringEscapeUtils.escapeHtml(newConf.getRaw(param)) +
"\" since approval</p>");
}
}
}
}
}
示例4: htmlUnescape
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Html 解码.
*/
public static String htmlUnescape(String htmlEscaped) {
return StringEscapeUtils.unescapeHtml(htmlEscaped);
}
示例5: htmlUnescape
import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
* Html 解码.
*/
public static String htmlUnescape(String htmlEscaped) {
return StringEscapeUtils.unescapeHtml(htmlEscaped);
}