當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。