org.apache.solr.common.util.XML.writeUnescapedXML()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(103)

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

XML.writeUnescapedXML介绍

[英]does NOT escape character data in val, must already be valid XML
[中]不转义val中的字符数据,必须已经是有效的XML

代码示例

代码示例来源:origin: org.apache.solr/solr-test-framework

/**
 * Generates a delete xml string
 * @param val text that has not already been xml escaped
 * @param args 0 and Even numbered args are params, Odd numbered args are XML escaped values.
 */
private static String delete(String val, String... args) {
 try {
  StringWriter r = new StringWriter();
  XML.writeUnescapedXML(r, "delete", val, (Object[]) args);
  return r.getBuffer().toString();
 } catch(IOException e) {
  throw new RuntimeException
    ("this should never happen with a StringWriter", e);
 }
}

代码示例来源:origin: org.dspace.dependencies.solr/dspace-solr-core

/**
 * Generates an <add><doc>... XML String with options
 * on the add.
 *
 * @param doc the Document to add
 * @param args 0th and Even numbered args are param names, Odds are param values.
 * @see #add
 * @see #doc
 */
public String add(Doc doc, String... args) {
 try {
  StringWriter r = new StringWriter();
     
  // this is anoying
  if (null == args || 0 == args.length) {
   r.write("<add>");
   r.write(doc.xml);
   r.write("</add>");
  } else {
   XML.writeUnescapedXML(r, "add", doc.xml, (Object[])args);
  }
     
  return r.getBuffer().toString();
 } catch (IOException e) {
  throw new RuntimeException
   ("this should never happen with a StringWriter", e);
 }
}

代码示例来源:origin: org.apache.solr/solr-test-framework

/**
 * Generates an &lt;add&gt;&lt;doc&gt;... XML String with options
 * on the add.
 *
 * @param doc the Document to add
 * @param args 0th and Even numbered args are param names, Odds are param values.
 * @see #add
 * @see #doc
 */
public static String add(XmlDoc doc, String... args) {
 try {
  StringWriter r = new StringWriter();
  // this is annoying
  if (null == args || 0 == args.length) {
   r.write("<add>");
   r.write(doc.xml);
   r.write("</add>");
  } else {
   XML.writeUnescapedXML(r, "add", doc.xml, (Object[])args);
  }
  return r.getBuffer().toString();
 } catch (IOException e) {
  throw new RuntimeException
   ("this should never happen with a StringWriter", e);
 }
}

相关文章