本文整理了Java中org.elasticsearch.common.xcontent.XContentBuilder.utf8Value()
方法的一些代码示例,展示了XContentBuilder.utf8Value()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XContentBuilder.utf8Value()
方法的具体详情如下:
包路径:org.elasticsearch.common.xcontent.XContentBuilder
类名称:XContentBuilder
方法名:utf8Value
[英]Writes the binary content of the given BytesRef as UTF-8 bytes. Use XContentParser#utf8Bytes() to read the value back
[中]将给定字节的二进制内容写入UTF-8字节。使用XContentParser#utf8Bytes()读回值
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (hasString()) {
return builder.value(this.string());
} else {
// TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a
// request to jackson to support InputStream as well?
BytesRef br = this.bytes().toBytesRef();
return builder.utf8Value(br.bytes, br.offset, br.length);
}
}
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* Writes the binary content of the given {@link BytesRef} as UTF-8 bytes.
*
* Use {@link XContentParser#utf8Bytes()} to read the value back
*/
public XContentBuilder utf8Field(String name, BytesRef value) throws IOException {
return field(name).utf8Value(value);
}
代码示例来源:origin: org.elasticsearch.client/elasticsearch-rest-high-level-client
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
byte[] charBytes = CharArrays.toUtf8Bytes(password);
try {
return builder.startObject()
.field("password").utf8Value(charBytes, 0, charBytes.length)
.endObject();
} finally {
Arrays.fill(charBytes, (byte) 0);
}
}
}
代码示例来源:origin: org.elasticsearch.client/elasticsearch-rest-high-level-client
private void charField(XContentBuilder builder, String fieldName, char[] chars) throws IOException {
byte[] charBytes = CharArrays.toUtf8Bytes(chars);
try {
builder.field(fieldName).utf8Value(charBytes, 0, charBytes.length);
} finally {
Arrays.fill(charBytes, (byte) 0);
}
}
}
代码示例来源:origin: org.elasticsearch.client/elasticsearch-rest-high-level-client
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject()
.field("grant_type", grantType);
if (scope != null) {
builder.field("scope", scope);
}
if (username != null) {
builder.field("username", username);
}
if (password != null) {
byte[] passwordBytes = CharArrays.toUtf8Bytes(password);
try {
builder.field("password").utf8Value(passwordBytes, 0, passwordBytes.length);
} finally {
Arrays.fill(passwordBytes, (byte) 0);
}
}
if (refreshToken != null) {
builder.field("refresh_token", refreshToken);
}
return builder.endObject();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (hasString()) {
return builder.value(this.string());
} else {
// TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a
// request to jackson to support InputStream as well?
BytesRef br = this.bytes().toBytesRef();
return builder.utf8Value(br.bytes, br.offset, br.length);
}
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (hasString()) {
return builder.value(this.string());
} else {
// TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a
// request to jackson to support InputStream as well?
BytesRef br = this.bytes().toBytesRef();
return builder.utf8Value(br.bytes, br.offset, br.length);
}
}
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
public XContentBuilder value(Text value) throws IOException {
if (value == null) {
return nullValue();
} else if (value.hasString()) {
return value(value.string());
} else {
// TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a
// request to jackson to support InputStream as well?
return utf8Value(value.bytes().toBytesRef());
}
}
内容来源于网络,如有侵权,请联系作者删除!