Package org.carrot2.elasticsearch.debug

Source Code of org.carrot2.elasticsearch.debug.XContentTests

package org.carrot2.elasticsearch.debug;

import java.io.ByteArrayOutputStream;

import org.elasticsearch.common.xcontent.XContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;

import com.google.common.io.Resources;

public class XContentTests {
    public static void main(String[] args) throws Exception {
        byte[] jsonResource = Resources.toByteArray(
                Resources.getResource(XContentTests.class, "post_cluster_by_url.json"));

        XContent xcontent = XContentFactory.xContent(jsonResource);
        XContentType type = XContentType.YAML; // xcontent.type();
        XContentParser parser = xcontent.createParser(jsonResource);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XContentBuilder builder = XContentFactory.contentBuilder(type, baos).copyCurrentStructure(parser);
        builder.close();

        System.out.println("Out:");
        System.out.println(new String(baos.toByteArray()));
    }
}
TOP

Related Classes of org.carrot2.elasticsearch.debug.XContentTests

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.