java.lang.Object
org.elasticsearch.xcontent.XContentFactory
A one stop to use
XContent
and XContentBuilder
.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic XContentBuilder
Returns a content builder using CBOR format (XContentType.CBOR
.static XContentBuilder
Constructs a new cbor builder that will output the result into the provided output stream.static XContentBuilder
contentBuilder
(XContentType type) Returns a binary content builder for the provided content type.static XContentBuilder
contentBuilder
(XContentType type, OutputStream outputStream) Constructs a xcontent builder that will output the result into the provided output stream.static XContentBuilder
Returns a content builder using JSON format (XContentType.JSON
.static XContentBuilder
Constructs a new json builder that will output the result into the provided output stream.static XContentBuilder
Returns a content builder using SMILE format (XContentType.SMILE
.static XContentBuilder
Constructs a new json builder that will output the result into the provided output stream.static XContent
xContent
(byte[] data) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContent
xContent
(byte[] data, int offset, int length) Deprecated.guessing the content type should not be needed ideally.static XContent
xContent
(CharSequence content) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContent
xContent
(XContentType type) Returns theXContent
for the provided content type.static XContentType
xContentType
(byte[] bytes) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContentType
xContentType
(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 XContentType
Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContentType
xContentType
(CharSequence content) Deprecated.the content type should not be guessed except for few cases where we effectively don't know the content type.static XContentBuilder
Returns a content builder using YAML format (XContentType.YAML
.static XContentBuilder
Constructs a new yaml builder that will output the result into the provided output stream.
-
Field Details
-
GUESS_HEADER_LENGTH
public static final int GUESS_HEADER_LENGTH- See Also:
-
-
Method Details
-
jsonBuilder
Returns a content builder using JSON format (XContentType.JSON
.- Throws:
IOException
-
jsonBuilder
Constructs a new json builder that will output the result into the provided output stream.- Throws:
IOException
-
smileBuilder
Returns a content builder using SMILE format (XContentType.SMILE
.- Throws:
IOException
-
smileBuilder
Constructs a new json builder that will output the result into the provided output stream.- Throws:
IOException
-
yamlBuilder
Returns a content builder using YAML format (XContentType.YAML
.- Throws:
IOException
-
yamlBuilder
Constructs a new yaml builder that will output the result into the provided output stream.- Throws:
IOException
-
cborBuilder
Returns a content builder using CBOR format (XContentType.CBOR
.- Throws:
IOException
-
cborBuilder
Constructs a new cbor builder that will output the result into the provided output stream.- Throws:
IOException
-
contentBuilder
public static XContentBuilder contentBuilder(XContentType type, OutputStream outputStream) throws IOException Constructs a xcontent builder that will output the result into the provided output stream.- Throws:
IOException
-
contentBuilder
Returns a binary content builder for the provided content type.- Throws:
IOException
-
xContent
Returns theXContent
for 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.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:
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.
-