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


Java CharArr.append方法代码示例

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


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

示例1: jsonAdd

import org.noggit.CharArr; //导入方法依赖的package包/类
/** Creates a JSON add command from a SolrInputDocument list.  Doesn't currently handle boosts. */
public static String jsonAdd(SolrInputDocument... docs) {
  CharArr out = new CharArr();
  try {
    out.append('[');
    boolean firstField = true;
    for (SolrInputDocument doc : docs) {
      if (firstField) firstField=false;
      else out.append(',');
      out.append(json(doc));
    }
    out.append(']');
  } catch (IOException e) {
    // should never happen
  }
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:SolrTestCaseJ4.java

示例2: jsonDelId

import org.noggit.CharArr; //导入方法依赖的package包/类
/** Creates a JSON delete command from an id list */
public static String jsonDelId(Object... ids) {
  CharArr out = new CharArr();
  try {
    out.append('{');
    boolean first = true;
    for (Object id : ids) {
      if (first) first=false;
      else out.append(',');
      out.append("\"delete\":{\"id\":");
      out.append(JSONUtil.toJSON(id));
      out.append('}');
    }
    out.append('}');
  } catch (IOException e) {
    // should never happen
  }
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:SolrTestCaseJ4.java

示例3: jsonDelQ

import org.noggit.CharArr; //导入方法依赖的package包/类
/** Creates a JSON deleteByQuery command */
public static String jsonDelQ(String... queries) {
  CharArr out = new CharArr();
  try {
    out.append('{');
    boolean first = true;
    for (Object q : queries) {
      if (first) first=false;
      else out.append(',');
      out.append("\"delete\":{\"query\":");
      out.append(JSONUtil.toJSON(q));
      out.append('}');
    }
    out.append('}');
  } catch (IOException e) {
    // should never happen
  }
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:SolrTestCaseJ4.java

示例4: toJSON

import org.noggit.CharArr; //导入方法依赖的package包/类
public static String toJSON(Doc doc) {
  CharArr out = new CharArr();
  try {
    out.append("{\"add\":{\"doc\":{");
    boolean firstField = true;
    for (Fld fld : doc.fields) {
      if (firstField) firstField=false;
      else out.append(',');
      JSONUtil.writeString(fld.ftype.fname, 0, fld.ftype.fname.length(), out);
      out.append(':');
      if (fld.vals.size() > 1) {
        out.append('[');
      }
      boolean firstVal = true;
      for (Comparable val : fld.vals) {
        if (firstVal) firstVal=false;
        else out.append(',');
        out.append(JSONUtil.toJSON(val));
      }
      if (fld.vals.size() > 1) {
        out.append(']');
      }
    }
    out.append("}}}");
  } catch (IOException e) {
    // should never happen
  }
  return out.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:SolrTestCaseJ4.java

示例5: json

import org.noggit.CharArr; //导入方法依赖的package包/类
/**
 * Appends to the <code>out</code> array with JSON from the <code>doc</code>.
 * Doesn't currently handle boosts, but does recursively handle child documents
 */
public static void json(SolrInputDocument doc, CharArr out) {
  try {
    out.append('{');
    boolean firstField = true;
    for (SolrInputField sfield : doc) {
      if (firstField) firstField=false;
      else out.append(',');
      JSONUtil.writeString(sfield.getName(), 0, sfield.getName().length(), out);
      out.append(':');

      if (sfield.getValueCount() > 1) {
        out.append('[');
        boolean firstVal = true;
        for (Object val : sfield) {
          if (firstVal) firstVal=false;
          else out.append(',');
          out.append(JSONUtil.toJSON(val));
        }
        out.append(']');
      } else {
        out.append(JSONUtil.toJSON(sfield.getValue()));
      }
    }

    boolean firstChildDoc = true;
    if(doc.hasChildDocuments()) {
      out.append(",\"_childDocuments_\": [");
      List<SolrInputDocument> childDocuments = doc.getChildDocuments();
      for(SolrInputDocument childDocument : childDocuments) {
        if (firstChildDoc) firstChildDoc=false;
        else out.append(',');
        json(childDocument, out);
      }
      out.append(']');
    }
    out.append('}');
  } catch (IOException e) {
    // should never happen
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:45,代码来源:SolrTestCaseJ4.java


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