Class XContentFactory
java.lang.Object
org.elasticsearch.common.xcontent.XContentFactory
public class XContentFactory
extends java.lang.Object
A one stop to use
XContent and XContentBuilder.-
Constructor Summary
Constructors Constructor Description XContentFactory() -
Method Summary
Modifier and Type Method Description static XContentBuildercborBuilder()Returns a content builder using CBOR format (XContentType.CBOR.static XContentBuildercborBuilder(java.io.OutputStream os)Constructs a new cbor builder that will output the result into the provided output stream.static XContentBuildercontentBuilder(XContentType type)Returns a binary content builder for the provided content type.static XContentBuildercontentBuilder(XContentType type, java.io.OutputStream outputStream)Constructs a xcontent builder that will output the result into the provided output stream.static XContentBuilderjsonBuilder()Returns a content builder using JSON format (XContentType.JSON.static XContentBuilderjsonBuilder(java.io.OutputStream os)Constructs a new json builder that will output the result into the provided output stream.static XContentBuildersmileBuilder()Returns a content builder using SMILE format (XContentType.SMILE.static XContentBuildersmileBuilder(java.io.OutputStream os)Constructs a new json builder that will output the result into the provided output stream.static XContentxContent(byte[] data)Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContentxContent(byte[] data, int offset, int length)Deprecated.guessing the content type should not be needed ideally.static XContentxContent(java.lang.CharSequence content)Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContentxContent(XContentType type)Returns theXContentfor the provided content type.static XContentTypexContentType(byte[] bytes)Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContentTypexContentType(byte[] bytes, int offset, int length)Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContentTypexContentType(java.io.InputStream si)Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContentTypexContentType(java.lang.CharSequence content)Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContentBuilderyamlBuilder()Returns a content builder using YAML format (XContentType.YAML.static XContentBuilderyamlBuilder(java.io.OutputStream os)Constructs a new yaml builder that will output the result into the provided output stream.
-
Constructor Details
-
XContentFactory
public XContentFactory()
-
-
Method Details
-
jsonBuilder
Returns a content builder using JSON format (XContentType.JSON.- Throws:
java.io.IOException
-
jsonBuilder
Constructs a new json builder that will output the result into the provided output stream.- Throws:
java.io.IOException
-
smileBuilder
Returns a content builder using SMILE format (XContentType.SMILE.- Throws:
java.io.IOException
-
smileBuilder
Constructs a new json builder that will output the result into the provided output stream.- Throws:
java.io.IOException
-
yamlBuilder
Returns a content builder using YAML format (XContentType.YAML.- Throws:
java.io.IOException
-
yamlBuilder
Constructs a new yaml builder that will output the result into the provided output stream.- Throws:
java.io.IOException
-
cborBuilder
Returns a content builder using CBOR format (XContentType.CBOR.- Throws:
java.io.IOException
-
cborBuilder
Constructs a new cbor builder that will output the result into the provided output stream.- Throws:
java.io.IOException
-
contentBuilder
public static XContentBuilder contentBuilder(XContentType type, java.io.OutputStream outputStream) throws java.io.IOExceptionConstructs a xcontent builder that will output the result into the provided output stream.- Throws:
java.io.IOException
-
contentBuilder
Returns a binary content builder for the provided content type.- Throws:
java.io.IOException
-
xContent
Returns theXContentfor the provided content type. -
xContentType
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided char sequence. -
xContent
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content (type) based on the provided char sequence and returns the correspondingXContent -
xContent
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided bytes and returns the correspondingXContent -
xContent
Deprecated.guessing the content type should not be needed ideally. We should rather know the content type upfront or read it from headers. Till we fixed the REST layer to read the Content-Type header, that should be the only place where guessing is needed.Guesses the content type based on the provided bytes and returns the correspondingXContent -
xContentType
@Deprecated public static XContentType xContentType(java.io.InputStream si) throws java.io.IOExceptionDeprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided input stream without consuming it.- Throws:
java.io.IOException
-
xContentType
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided bytes. -
xContentType
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type. The REST layer should move to reading the Content-Type header instead. There are other places where auto-detection may be needed. This method is deprecated to prevent usages of it from spreading further without specific reasons.Guesses the content type based on the provided bytes.
-