当前位置: 首页>>代码示例>>Java>>正文


Java XContentType.YAML属性代码示例

本文整理汇总了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;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:ClientYamlTestResponse.java

示例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 + "]");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:SettingsLoaderFactory.java

示例3: contentType

@Override
public XContentType contentType() {
    return XContentType.YAML;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:YamlSettingsLoader.java

示例4: type

@Override
public XContentType type() {
    return XContentType.YAML;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:YamlXContent.java

示例5: xcontentType

@Override
public XContentType xcontentType() {
    return XContentType.YAML;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:YamlXContentTests.java

示例6: getXContentType

@Override
protected XContentType getXContentType() {
    return XContentType.YAML;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:YamlFilteringGeneratorTests.java


注:本文中的org.elasticsearch.common.xcontent.XContentType.YAML属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。