org.elasticsearch.common.xcontent.XContentBuilder.lfAtEnd()方法的使用及代码示例

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

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

XContentBuilder.lfAtEnd介绍

[英]Indicate that the current XContentBuilder must write a line feed ("\n") at the end of the built object.

This only applies for JSON XContent type. It has no effect for other types.
[中]指示当前XContentBuilder必须在生成对象的末尾写入换行符(“\n”)。
这只适用于JSON XContent类型。它对其他类型没有影响。

代码示例

代码示例来源:origin: richardwilly98/elasticsearch-river-mongodb

public static XContentBuilder restContentBuilder(RestRequest request, @Nullable BytesReference autoDetectSource) throws IOException {
  XContentType contentType = XContentType.fromRestContentType(request.param("format", request.header("Content-Type")));
  if (contentType == null) {
    // try and guess it from the auto detect source
    if (autoDetectSource != null) {
      contentType = XContentFactory.xContentType(autoDetectSource);
    }
  }
  if (contentType == null) {
    // default to JSON
    contentType = XContentType.JSON;
  }
  XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), new BytesStreamOutput());
  if (request.paramAsBoolean("pretty", false)) {
    builder.prettyPrint().lfAtEnd();
  }
  builder.humanReadable(request.paramAsBoolean("human", builder.humanReadable()));
  String casing = request.param("case");
  if (casing != null && "camelCase".equals(casing)) {
    builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
  } else {
    // we expect all REST interfaces to write results in underscore casing, so
    // no need for double casing
    builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.NONE);
  }
  return builder;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

new XContentBuilder(XContentFactory.xContent(responseContentType), unclosableOutputStream, includes, excludes);
if (pretty) {
  builder.prettyPrint().lfAtEnd();

代码示例来源:origin: org.elasticsearch/elasticsearch

static BytesRestResponse convertMainResponse(MainResponse response, RestRequest request, XContentBuilder builder) throws IOException {
  RestStatus status = response.isAvailable() ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE;
  // Default to pretty printing, but allow ?pretty=false to disable
  if (request.hasParam("pretty") == false) {
    builder.prettyPrint().lfAtEnd();
  }
  response.toXContent(builder, request);
  return new BytesRestResponse(status, builder);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

new XContentBuilder(XContentFactory.xContent(responseContentType), unclosableOutputStream, includes, excludes);
if (pretty) {
  builder.prettyPrint().lfAtEnd();

代码示例来源:origin: dremio/dremio-oss

public static String queryAsJson(QueryBuilder query) throws IOException {
 XContentBuilder x = XContentFactory.jsonBuilder();
 x.prettyPrint().lfAtEnd();
 query.toXContent(x, ToXContent.EMPTY_PARAMS);
 return x.string();
}

代码示例来源:origin: apache/servicemix-bundles

new XContentBuilder(XContentFactory.xContent(responseContentType), unclosableOutputStream, includes, excludes);
if (pretty) {
  builder.prettyPrint().lfAtEnd();

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

new XContentBuilder(XContentFactory.xContent(responseContentType), unclosableOutputStream, includes, excludes);
if (pretty) {
  builder.prettyPrint().lfAtEnd();

代码示例来源:origin: codelibs/elasticsearch-taste

private void sendResponse(final RestRequest request,
    final RestChannel channel, final Map<String, Object> params,
    final boolean acknowledged) {
  try {
    final XContentBuilder builder = JsonXContent.contentBuilder();
    if (request.hasParam("pretty")) {
      builder.prettyPrint().lfAtEnd();
    }
    builder.startObject();
    builder.field("acknowledged", acknowledged);
    if (params != null) {
      for (final Map.Entry<String, Object> entry : params.entrySet()) {
        builder.field(entry.getKey(), entry.getValue());
      }
    }
    builder.endObject();
    channel.sendResponse(new BytesRestResponse(OK, builder));
  } catch (final Exception e) {
    sendErrorResponse(channel, e);
  }
}

代码示例来源:origin: codelibs/elasticsearch-reindexing

private void sendResponse(final RestRequest request,
    final RestChannel channel, final Map<String, Object> params) {
  try {
    final XContentBuilder builder = JsonXContent.contentBuilder();
    if (request.hasParam("pretty")) {
      builder.prettyPrint().lfAtEnd();
    }
    builder.startObject();
    builder.field("acknowledged", true);
    if (params != null) {
      for (final Map.Entry<String, Object> entry : params.entrySet()) {
        builder.field(entry.getKey(), entry.getValue());
      }
    }
    builder.endObject();
    channel.sendResponse(new BytesRestResponse(OK, builder));
  } catch (final Exception e) {
    sendErrorResponse(channel, e);
  }
}

代码示例来源:origin: codelibs/elasticsearch-dataformat

private void sendResponse(final RestRequest request, final RestChannel channel, final String file) {
  try {
    final XContentBuilder builder = JsonXContent.contentBuilder();
    final String pretty = request.param("pretty");
    if (pretty != null && !"false".equalsIgnoreCase(pretty)) {
      builder.prettyPrint().lfAtEnd();
    }
    builder.startObject();
    builder.field("acknowledged", true);
    builder.field("file", file);
    builder.endObject();
    channel.sendResponse(new BytesRestResponse(OK, builder));
  } catch (final IOException e) {
    throw new ElasticsearchException("Failed to create a resposne.", e);
  }
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

static BytesRestResponse convertMainResponse(MainResponse response, RestRequest request, XContentBuilder builder) throws IOException {
    RestStatus status = response.isAvailable() ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE;

    // Default to pretty printing, but allow ?pretty=false to disable
    if (request.hasParam("pretty") == false) {
      builder.prettyPrint().lfAtEnd();
    }
    response.toXContent(builder, request);
    return new BytesRestResponse(status, builder);
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

static BytesRestResponse convertMainResponse(MainResponse response, RestRequest request, XContentBuilder builder) throws IOException {
  RestStatus status = response.isAvailable() ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE;
  // Default to pretty printing, but allow ?pretty=false to disable
  if (request.hasParam("pretty") == false) {
    builder.prettyPrint().lfAtEnd();
  }
  response.toXContent(builder, request);
  return new BytesRestResponse(status, builder);
}

代码示例来源:origin: apache/servicemix-bundles

static BytesRestResponse convertMainResponse(MainResponse response, RestRequest request, XContentBuilder builder) throws IOException {
    RestStatus status = response.isAvailable() ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE;

    // Default to pretty printing, but allow ?pretty=false to disable
    if (request.hasParam("pretty") == false) {
      builder.prettyPrint().lfAtEnd();
    }
    response.toXContent(builder, request);
    return new BytesRestResponse(status, builder);
  }
}

代码示例来源:origin: codelibs/elasticsearch-taste

final String pretty = request.param("pretty");
if (pretty != null && !"false".equalsIgnoreCase(pretty)) {
  builder.prettyPrint().lfAtEnd();

代码示例来源:origin: searchisko/elasticsearch-river-jira

public static XContentBuilder restContentBuilder(RestRequest request) throws IOException {
  XContentType contentType = XContentType
      .fromRestContentType(request.param("format", request.header("Content-Type")));
  if (contentType == null) {
    // default to JSON
    contentType = XContentType.JSON;
  }
  XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), new BytesStreamOutput());
  if (request.paramAsBoolean("pretty", false)) {
    builder.prettyPrint().lfAtEnd();
  }
  String casing = request.param("case");
  if (casing != null && "camelCase".equals(casing)) {
    builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
  } else {
    // we expect all REST interfaces to write results in underscore casing, so
    // no need for double casing
    builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.NONE);
  }
  return builder;
}

代码示例来源:origin: jprante/elasticsearch-transport-websocket

public static XContentBuilder restContentBuilder(RestRequest request) throws IOException {
  XContentType contentType = XContentType.fromRestContentType(request.param("format", request.header("Content-Type")));
  if (contentType == null) {
    // default to JSON
    contentType = XContentType.JSON;
  }
  XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType),
      new BytesStreamOutput());
  if (request.paramAsBoolean("pretty", false)) {
    builder.prettyPrint().lfAtEnd();
  }
  String casing = request.param("case");
  if (casing != null && "camelCase".equals(casing)) {
    builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.CAMELCASE);
  } else {
    // we expect all REST interfaces to write results in underscore casing, so
    // no need for double casing
    builder.fieldCaseConversion(XContentBuilder.FieldCaseConversion.NONE);
  }
  return builder;
}

代码示例来源:origin: codelibs/elasticsearch-taste

final String pretty = request.param("pretty");
if (pretty != null && !"false".equalsIgnoreCase(pretty)) {
  builder.prettyPrint().lfAtEnd();

代码示例来源:origin: harbby/presto-connectors

builder.prettyPrint().lfAtEnd();

代码示例来源:origin: harbby/presto-connectors

XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), bytesOutput(), filters);
if (request.paramAsBoolean("pretty", false)) {
  builder.prettyPrint().lfAtEnd();

相关文章

微信公众号

最新文章

更多