当前位置: 首页>>代码示例>>Java>>正文


Java StringEscapeUtils.unescapeHtml方法代码示例

本文整理汇总了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;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:35,代码来源:AnnotationDrawUtils.java

示例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;amp;' might occur
        ret = StringEscapeUtils.unescapeHtml(ret);
    }

    return ret;
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:15,代码来源:MetadataHelper.java

示例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>");
        }
      }
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:62,代码来源:ReconfigurationServlet.java

示例4: htmlUnescape

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Html 解码.
 */
public static String htmlUnescape(String htmlEscaped) {
    return StringEscapeUtils.unescapeHtml(htmlEscaped);
}
 
开发者ID:dragon-yuan,项目名称:Ins_fb_pictureSpider_WEB,代码行数:7,代码来源:EncodeUtils.java

示例5: htmlUnescape

import org.apache.commons.lang.StringEscapeUtils; //导入方法依赖的package包/类
/**
 * Html 解码.
 */
public static String htmlUnescape(String htmlEscaped) {
	return StringEscapeUtils.unescapeHtml(htmlEscaped);
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:7,代码来源:EncodeUtils.java


注:本文中的org.apache.commons.lang.StringEscapeUtils.unescapeHtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。