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


Java ClientUtils.writeXML方法代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.util.ClientUtils.writeXML方法的典型用法代码示例。如果您正苦于以下问题:Java ClientUtils.writeXML方法的具体用法?Java ClientUtils.writeXML怎么用?Java ClientUtils.writeXML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.client.solrj.util.ClientUtils的用法示例。


在下文中一共展示了ClientUtils.writeXML方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getXML

import org.apache.solr.client.solrj.util.ClientUtils; //导入方法依赖的package包/类
/**
 * Returns the xml be be set as the request body.
 *
 * @return The xml be be set as the request body.
 *
 * @throws IOException When constructing the xml fails
 */
String getXML() throws IOException {
  StringWriter writer = new StringWriter();
  writer.write("<docs>");
  for (SolrInputDocument document : documents) {
    ClientUtils.writeXML(document, writer);
  }
  writer.write("</docs>");
  writer.flush();

  String xml = writer.toString();
  return (xml.length() > 0) ? xml : null;
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:DocumentAnalysisRequest.java

示例2: adoc

import org.apache.solr.client.solrj.util.ClientUtils; //导入方法依赖的package包/类
/**
 * Generates a simple &lt;add&gt;&lt;doc&gt;... XML String with no options
 */
public static String adoc(SolrInputDocument sdoc) {
  StringWriter out = new StringWriter(512);
  try {
    out.append("<add>");
    ClientUtils.writeXML(sdoc, out);
    out.append("</add>");
  } catch (IOException e) {
    throw new RuntimeException("Inexplicable IO error from StringWriter", e);
  }
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:SolrTestCaseJ4.java

示例3: writeXML

import org.apache.solr.client.solrj.util.ClientUtils; //导入方法依赖的package包/类
public void writeXML(Writer writer) throws IOException {
  List<List<SolrDoc>> getDocLists = getDocLists(documents);
  
  for (List<SolrDoc> docs : getDocLists) {
    
    if ((docs != null && docs.size() > 0)) {
      SolrDoc firstDoc = docs.get(0);
      int commitWithin = firstDoc.commitWithin != -1 ? firstDoc.commitWithin : this.commitWithin;
      boolean overwrite = firstDoc.overwrite;
      if (commitWithin > -1 || overwrite != true) {
        writer.write("<add commitWithin=\"" + commitWithin + "\" " + "overwrite=\"" + overwrite + "\">");
      } else {
        writer.write("<add>");
      }
      if (documents != null) {
        for (SolrDoc doc : documents) {
          if (doc != null) {
            ClientUtils.writeXML(doc.document, writer);
          }
        }
      }
      
      writer.write("</add>");
    }
  }
  
  // Add the delete commands
  boolean deleteI = deleteById != null && deleteById.size() > 0;
  boolean deleteQ = deleteQuery != null && deleteQuery.size() > 0;
  if (deleteI || deleteQ) {
    writer.append("<delete>");
    if (deleteI) {
      for (Map.Entry<String,Long> entry : deleteById.entrySet()) {
        writer.append("<id");
        Long version = entry.getValue();
        if (version != null) {
          writer.append(" version=\"" + version + "\"");
        }
        writer.append(">");
        
        XML.escapeCharData(entry.getKey(), writer);
        writer.append("</id>");
      }
    }
    if (deleteQ) {
      for (String q : deleteQuery) {
        writer.append("<query>");
        XML.escapeCharData(q, writer);
        writer.append("</query>");
      }
    }
    writer.append("</delete>");
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:55,代码来源:UpdateRequestExt.java


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