本文整理匯總了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;
}