本文整理汇总了Java中org.elasticsearch.common.xcontent.XContentType.YAML属性的典型用法代码示例。如果您正苦于以下问题:Java XContentType.YAML属性的具体用法?Java XContentType.YAML怎么用?Java XContentType.YAML使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.elasticsearch.common.xcontent.XContentType
的用法示例。
在下文中一共展示了XContentType.YAML属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBodyAsString
/**
* Returns the body as a string
*/
public String getBodyAsString() {
if (bodyAsString == null && body != null) {
//content-type null means that text was returned
if (bodyContentType == null || bodyContentType == XContentType.JSON || bodyContentType == XContentType.YAML) {
bodyAsString = new String(body, StandardCharsets.UTF_8);
} else {
//if the body is in a binary format and gets requested as a string (e.g. to log a test failure), we convert it to json
try (XContentBuilder jsonBuilder = XContentFactory.jsonBuilder()) {
try (XContentParser parser = bodyContentType.xContent().createParser(NamedXContentRegistry.EMPTY, body)) {
jsonBuilder.copyCurrentStructure(parser);
}
bodyAsString = jsonBuilder.string();
} catch (IOException e) {
throw new UncheckedIOException("unable to convert response body to a string format", e);
}
}
}
return bodyAsString;
}
示例2: loaderFromXContentType
/**
* Returns a {@link SettingsLoader} based on the {@link XContentType}. Note only {@link XContentType#JSON} and
* {@link XContentType#YAML} are supported
*
* @param xContentType The content type
* @return A settings loader.
*/
public static SettingsLoader loaderFromXContentType(XContentType xContentType) {
if (xContentType == XContentType.JSON) {
return new JsonSettingsLoader(true);
} else if (xContentType == XContentType.YAML) {
return new YamlSettingsLoader(true);
} else {
throw new IllegalArgumentException("unsupported content type [" + xContentType + "]");
}
}
示例3: contentType
@Override
public XContentType contentType() {
return XContentType.YAML;
}
示例4: type
@Override
public XContentType type() {
return XContentType.YAML;
}
示例5: xcontentType
@Override
public XContentType xcontentType() {
return XContentType.YAML;
}
示例6: getXContentType
@Override
protected XContentType getXContentType() {
return XContentType.YAML;
}