本文整理了Java中org.elasticsearch.common.Strings.createBuilder()
方法的一些代码示例,展示了Strings.createBuilder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Strings.createBuilder()
方法的具体详情如下:
包路径:org.elasticsearch.common.Strings
类名称:Strings
方法名:createBuilder
暂无
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Return a {@link String} that is the json representation of the provided {@link ToXContent}.
* Wraps the output into an anonymous object if needed. Allows to control whether the outputted
* json needs to be pretty printed and human readable.
*
*/
public static String toString(ToXContent toXContent, boolean pretty, boolean human) {
try {
XContentBuilder builder = createBuilder(pretty, human);
if (toXContent.isFragment()) {
builder.startObject();
}
toXContent.toXContent(builder, ToXContent.EMPTY_PARAMS);
if (toXContent.isFragment()) {
builder.endObject();
}
return toString(builder);
} catch (IOException e) {
try {
XContentBuilder builder = createBuilder(pretty, human);
builder.startObject();
builder.field("error", "error building toString out of XContent: " + e.getMessage());
builder.field("stack_trace", ExceptionsHelper.stackTrace(e));
builder.endObject();
return toString(builder);
} catch (IOException e2) {
throw new ElasticsearchException("cannot generate error message for deserialization", e);
}
}
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Return a {@link String} that is the json representation of the provided {@link ToXContent}.
* Wraps the output into an anonymous object if needed. Allows to control whether the outputted
* json needs to be pretty printed and human readable.
*
*/
public static String toString(ToXContent toXContent, boolean pretty, boolean human) {
try {
XContentBuilder builder = createBuilder(pretty, human);
if (toXContent.isFragment()) {
builder.startObject();
}
toXContent.toXContent(builder, ToXContent.EMPTY_PARAMS);
if (toXContent.isFragment()) {
builder.endObject();
}
return toString(builder);
} catch (IOException e) {
try {
XContentBuilder builder = createBuilder(pretty, human);
builder.startObject();
builder.field("error", "error building toString out of XContent: " + e.getMessage());
builder.field("stack_trace", ExceptionsHelper.stackTrace(e));
builder.endObject();
return toString(builder);
} catch (IOException e2) {
throw new ElasticsearchException("cannot generate error message for deserialization", e);
}
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
/**
* Return a {@link String} that is the json representation of the provided {@link ToXContent}.
* Wraps the output into an anonymous object if needed. Allows to control whether the outputted
* json needs to be pretty printed and human readable.
*
*/
public static String toString(ToXContent toXContent, boolean pretty, boolean human) {
try {
XContentBuilder builder = createBuilder(pretty, human);
if (toXContent.isFragment()) {
builder.startObject();
}
toXContent.toXContent(builder, ToXContent.EMPTY_PARAMS);
if (toXContent.isFragment()) {
builder.endObject();
}
return toString(builder);
} catch (IOException e) {
try {
XContentBuilder builder = createBuilder(pretty, human);
builder.startObject();
builder.field("error", "error building toString out of XContent: " + e.getMessage());
builder.field("stack_trace", ExceptionsHelper.stackTrace(e));
builder.endObject();
return toString(builder);
} catch (IOException e2) {
throw new ElasticsearchException("cannot generate error message for deserialization", e);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!