org.apache.commons.lang3.StringEscapeUtils.unescapeXml()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中org.apache.commons.lang3.StringEscapeUtils.unescapeXml()方法的一些代码示例,展示了StringEscapeUtils.unescapeXml()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringEscapeUtils.unescapeXml()方法的具体详情如下:
包路径:org.apache.commons.lang3.StringEscapeUtils
类名称:StringEscapeUtils
方法名:unescapeXml

StringEscapeUtils.unescapeXml介绍

[英]Unescapes a string containing XML entity escapes to a string containing the actual Unicode characters corresponding to the escapes.

Supports only the five basic XML entities (gt, lt, quot, amp, apos). Does not support DTDs or external entities.

Note that numerical \u Unicode codes are unescaped to their respective Unicode characters. This may change in future releases.
[中]unescape将包含XML实体转义的字符串转换为包含与转义相对应的实际Unicode字符的字符串。
仅支持五个基本XML实体(gt、lt、QUOTE、amp、apos)。不支持DTD或外部实体。
请注意,数字\u Unicode代码未转换为各自的Unicode字符。这在未来的版本中可能会发生变化。

代码示例

代码示例来源:origin: springside/springside4

/**
 * Xml转码,XML格式的字符串解码为普通字符串.
 * 
 * 比如 "bread" & "butter" 转化为"bread" & "butter"
 */
public static String unescapeXml(String xml) {
  return StringEscapeUtils.unescapeXml(xml);
}

代码示例来源:origin: gocd/gocd

private List<File> parseFiles(Element filesElement, String fileType) {
  List files = filesElement.getChild(fileType).getChildren("file");
  List<File> modifiedFiles = new ArrayList<>();
  for (Iterator iterator = files.iterator(); iterator.hasNext();) {
    Element node = (Element) iterator.next();
    modifiedFiles.add(new File(org.apache.commons.lang3.StringEscapeUtils.unescapeXml(node.getText())));
  }
  return modifiedFiles;
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Reverse of the above.
 *
 * @see <a href="https://issues.apache.org/jira/browse/LANG-729">LANG-729</a>
 */
@Test
public void testUnescapeXmlSupplementaryCharacters() {
  assertEquals("Supplementary character must be represented using a single escape", "\uD84C\uDFB4",
      StringEscapeUtils.unescapeXml("&#144308;") );
  assertEquals("Supplementary characters mixed with basic characters should be decoded correctly", "a b c \uD84C\uDFB4",
      StringEscapeUtils.unescapeXml("a b c &#144308;") );
}

代码示例来源:origin: gocd/gocd

private Modification parseChangeset(Element changeset) {
  Date modifiedTime = DateUtils.parseRFC822(changeset.getChildText("date"));
  String author = org.apache.commons.lang3.StringEscapeUtils.unescapeXml(changeset.getChildText("author"));
  String comment = org.apache.commons.lang3.StringEscapeUtils.unescapeXml(changeset.getChildText("desc"));
  String revision = changeset.getChildText("node");
  Modification modification = new Modification(author, comment, null, modifiedTime, revision);
  Element files = changeset.getChild("files");
  List<File> modifiedFiles = parseFiles(files, "modified");
  List<File> addedFiles = parseFiles(files, "added");
  List<File> deletedFiles = parseFiles(files, "deleted");
  modifiedFiles.removeAll(addedFiles);
  modifiedFiles.removeAll(deletedFiles);
  addModificationFiles(modification, ModifiedAction.added, addedFiles);
  addModificationFiles(modification, ModifiedAction.deleted, deletedFiles);
  addModificationFiles(modification, ModifiedAction.modified, modifiedFiles);
  return modification;
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testStandaloneAmphersand() {
  assertEquals("<P&O>", StringEscapeUtils.unescapeHtml4("&lt;P&O&gt;"));
  assertEquals("test & <", StringEscapeUtils.unescapeHtml4("test & &lt;"));
  assertEquals("<P&O>", StringEscapeUtils.unescapeXml("&lt;P&O&gt;"));
  assertEquals("test & <", StringEscapeUtils.unescapeXml("test & &lt;"));
}

代码示例来源:origin: org.apache.commons/commons-lang3

@Test
public void testEscapeXml() throws Exception {
  assertEquals("&lt;abc&gt;", StringEscapeUtils.escapeXml("<abc>"));
  assertEquals("<abc>", StringEscapeUtils.unescapeXml("&lt;abc&gt;"));
      "\u00A0", StringEscapeUtils.unescapeXml("&#160;"));
  assertEquals("XML should be able to unescape >0x7f values with one leading 0",
      "\u00A0", StringEscapeUtils.unescapeXml("&#0160;"));
  assertEquals("XML should be able to unescape >0x7f values with two leading 0s",
      "\u00A0", StringEscapeUtils.unescapeXml("&#00160;"));
  assertEquals("XML should be able to unescape >0x7f values with three leading 0s",
      "\u00A0", StringEscapeUtils.unescapeXml("&#000160;"));
  assertEquals("ain't", StringEscapeUtils.unescapeXml("ain&apos;t"));
  assertEquals("ain&apos;t", StringEscapeUtils.escapeXml("ain't"));
  assertEquals("", StringEscapeUtils.escapeXml(""));
  assertNull(StringEscapeUtils.escapeXml(null));
  assertNull(StringEscapeUtils.unescapeXml(null));

代码示例来源:origin: jobxhub/JobX

/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
  return StringEscapeUtils.unescapeXml(xmlEscaped);
}

代码示例来源:origin: xuminwlt/j360-dubbo-app-all

/**
 * Xml转码,XML格式的字符串解码为普通字符串.
 * 
 * 比如 &quot;bread&quot; &amp; &quot;butter&quot; 转化为"bread" & "butter"
 */
public static String unescapeXml(String xml) {
  return StringEscapeUtils.unescapeXml(xml);
}

代码示例来源:origin: com.centit.support/centit-utils

public static String decodeString(String xmlData)
{
  return StringEscapeUtils.unescapeXml(xmlData);
  /*String strData = xmlData.replaceAll("&lt;", "<");
   strData = strData.replaceAll( "&gt;", ">");
   strData = strData.replaceAll("&apos;", "'");
   strData = strData.replaceAll("&quot;", "\"");
   strData = strData.replaceAll( "&amp;", "&");
   return strData;  */
}

代码示例来源:origin: com.quhaodian/user_hibernate

/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
  return StringEscapeUtils.unescapeXml(xmlEscaped);
}

代码示例来源:origin: tangyanbo/springmore

/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
  return StringEscapeUtils.unescapeXml(xmlEscaped);
}

代码示例来源:origin: com.quhaodian.discover/discover-user

/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
 return StringEscapeUtils.unescapeXml(xmlEscaped);
}

代码示例来源:origin: com.github.dactiv/dactiv-common

/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
  return StringEscapeUtils.unescapeXml(xmlEscaped);
}

代码示例来源:origin: lcw2004/one

/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
  return StringEscapeUtils.unescapeXml(xmlEscaped);
}

代码示例来源:origin: DarLiner/vjtools

/**
 * Xml转码,XML格式的字符串解码为普通字符串.
 * 
 * 比如 &quot;bread&quot; &amp; &quot;butter&quot; 转化为"bread" & "butter"
 */
public static String unescapeXml(String xml) {
  return StringEscapeUtils.unescapeXml(xml);
}

代码示例来源:origin: xautlx/s2jh4net

/**
 * Xml 解码.
 */
public static String unescapeXml(String xmlEscaped) {
  return StringEscapeUtils.unescapeXml(xmlEscaped);
}

代码示例来源:origin: tinyMediaManager/tinyMediaManager

/**
 * Gets the proxy password.
 * 
 * @return the proxy password
 */
@XmlElement(name = PROXY_PASSWORD)
@XmlJavaTypeAdapter(EncryptedStringXmlAdapter.class)
public String getProxyPassword() {
 return StringEscapeUtils.unescapeXml(proxyPassword);
}

代码示例来源:origin: net.open-esb.admin/openesb-java-sdk

@Override
public String getComponentDescriptor(GetComponentDescriptorRequest request) throws OpenESBClientException {
  return StringEscapeUtils.unescapeXml(
      executeRequest(request,
      null,
      new StringResponseHandler()));
}

代码示例来源:origin: org.xworker/xworker_core

public static String unescapeXml(ActionContext actionContext){
  Thing self = actionContext.getObject("self");
  String str  = (String) self.doAction("getStr", actionContext);
  return StringEscapeUtils.unescapeXml(str);
}

代码示例来源:origin: net.open-esb.admin/openesb-java-sdk

@Override
public String getServiceAssemblyDescriptor(GetServiceAssemblyDescriptorRequest request) throws Exception {
  return StringEscapeUtils.unescapeXml(
      executeRequest(
      request,
      null,
      new StringResponseHandler()));
}

相关文章