public class XContentHelper
extends java.lang.Object
| Constructor and Description |
|---|
XContentHelper() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
convertToJson(BytesReference bytes,
boolean reformatJson)
Deprecated.
|
static java.lang.String |
convertToJson(BytesReference bytes,
boolean reformatJson,
boolean prettyPrint)
Deprecated.
|
static java.lang.String |
convertToJson(BytesReference bytes,
boolean reformatJson,
boolean prettyPrint,
XContentType xContentType) |
static java.lang.String |
convertToJson(BytesReference bytes,
boolean reformatJson,
XContentType xContentType) |
static Tuple<XContentType,java.util.Map<java.lang.String,java.lang.Object>> |
convertToMap(BytesReference bytes,
boolean ordered)
Deprecated.
this method relies on auto-detection of content type. Use
convertToMap(BytesReference, boolean, XContentType)
instead with the proper XContentType |
static Tuple<XContentType,java.util.Map<java.lang.String,java.lang.Object>> |
convertToMap(BytesReference bytes,
boolean ordered,
XContentType xContentType)
Converts the given bytes into a map that is optionally ordered.
|
static java.util.Map<java.lang.String,java.lang.Object> |
convertToMap(XContent xContent,
java.io.InputStream input,
boolean ordered)
Convert a string in some
XContent format to a Map. |
static java.util.Map<java.lang.String,java.lang.Object> |
convertToMap(XContent xContent,
java.lang.String string,
boolean ordered)
Convert a string in some
XContent format to a Map. |
static void |
copyCurrentEvent(XContentGenerator generator,
XContentParser parser) |
static void |
copyCurrentStructure(XContentGenerator destination,
XContentParser parser)
Low level implementation detail of
XContentGenerator.copyCurrentStructure(XContentParser). |
static XContentParser |
createParser(NamedXContentRegistry xContentRegistry,
BytesReference bytes)
Deprecated.
use
createParser(NamedXContentRegistry, BytesReference, XContentType) to avoid content type auto-detection |
static XContentParser |
createParser(NamedXContentRegistry xContentRegistry,
BytesReference bytes,
XContentType xContentType)
Creates a parser for the bytes using the supplied content-type
|
static void |
mergeDefaults(java.util.Map<java.lang.String,java.lang.Object> content,
java.util.Map<java.lang.String,java.lang.Object> defaults)
Merges the defaults provided as the second parameter into the content of the first.
|
static java.lang.String |
toString(ToXContent toXContent)
Writes serialized toXContent to pretty-printed JSON string.
|
static java.lang.String |
toString(ToXContent toXContent,
ToXContent.Params params)
Writes serialized toXContent to pretty-printed JSON string.
|
static BytesReference |
toXContent(ToXContent toXContent,
XContentType xContentType,
boolean humanReadable)
Returns the bytes that represent the XContent output of the provided
ToXContent object, using the provided
XContentType. |
static BytesReference |
toXContent(ToXContent toXContent,
XContentType xContentType,
ToXContent.Params params,
boolean humanReadable)
Returns the bytes that represent the XContent output of the provided
ToXContent object, using the provided
XContentType. |
static boolean |
update(java.util.Map<java.lang.String,java.lang.Object> source,
java.util.Map<java.lang.String,java.lang.Object> changes,
boolean checkUpdatesAreUnequal)
Updates the provided changes into the source.
|
static void |
writeRawField(java.lang.String field,
BytesReference source,
XContentBuilder builder,
ToXContent.Params params)
Deprecated.
use
#writeRawField(String, BytesReference, XContentType, XContentBuilder, Params) to avoid content type
auto-detection |
static void |
writeRawField(java.lang.String field,
BytesReference source,
XContentType xContentType,
XContentBuilder builder,
ToXContent.Params params)
Writes a "raw" (bytes) field, handling cases where the bytes are compressed, and tries to optimize writing using
XContentBuilder.rawField(String, org.elasticsearch.common.bytes.BytesReference, XContentType). |
@Deprecated public static XContentParser createParser(NamedXContentRegistry xContentRegistry, BytesReference bytes) throws java.io.IOException
createParser(NamedXContentRegistry, BytesReference, XContentType) to avoid content type auto-detectionjava.io.IOExceptionpublic static XContentParser createParser(NamedXContentRegistry xContentRegistry, BytesReference bytes, XContentType xContentType) throws java.io.IOException
java.io.IOException@Deprecated public static Tuple<XContentType,java.util.Map<java.lang.String,java.lang.Object>> convertToMap(BytesReference bytes, boolean ordered) throws ElasticsearchParseException
convertToMap(BytesReference, boolean, XContentType)
instead with the proper XContentTypeElasticsearchParseExceptionpublic static Tuple<XContentType,java.util.Map<java.lang.String,java.lang.Object>> convertToMap(BytesReference bytes, boolean ordered, XContentType xContentType) throws ElasticsearchParseException
XContentType must be non-null.ElasticsearchParseExceptionpublic static java.util.Map<java.lang.String,java.lang.Object> convertToMap(XContent xContent, java.lang.String string, boolean ordered) throws ElasticsearchParseException
XContent format to a Map. Throws an ElasticsearchParseException if there is any
error.ElasticsearchParseExceptionpublic static java.util.Map<java.lang.String,java.lang.Object> convertToMap(XContent xContent, java.io.InputStream input, boolean ordered) throws ElasticsearchParseException
XContent format to a Map. Throws an ElasticsearchParseException if there is any
error. Note that unlike convertToMap(BytesReference, boolean), this doesn't automatically uncompress the input.ElasticsearchParseException@Deprecated public static java.lang.String convertToJson(BytesReference bytes, boolean reformatJson) throws java.io.IOException
java.io.IOException@Deprecated public static java.lang.String convertToJson(BytesReference bytes, boolean reformatJson, boolean prettyPrint) throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String convertToJson(BytesReference bytes, boolean reformatJson, XContentType xContentType) throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String convertToJson(BytesReference bytes, boolean reformatJson, boolean prettyPrint, XContentType xContentType) throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String toString(ToXContent toXContent)
toXContent - object to be pretty printedpublic static java.lang.String toString(ToXContent toXContent, ToXContent.Params params)
toXContent - object to be pretty printedparams - serialization parameterspublic static boolean update(java.util.Map<java.lang.String,java.lang.Object> source,
java.util.Map<java.lang.String,java.lang.Object> changes,
boolean checkUpdatesAreUnequal)
source - the original map to be updatedchanges - the changes to update into updatedcheckUpdatesAreUnequal - should this method check if updates to the same key (that are not both maps) are
unequal? This is just a .equals check on the objects, but that can take some time on long strings.public static void mergeDefaults(java.util.Map<java.lang.String,java.lang.Object> content,
java.util.Map<java.lang.String,java.lang.Object> defaults)
public static void copyCurrentStructure(XContentGenerator destination, XContentParser parser) throws java.io.IOException
XContentGenerator.copyCurrentStructure(XContentParser).java.io.IOExceptionpublic static void copyCurrentEvent(XContentGenerator generator, XContentParser parser) throws java.io.IOException
java.io.IOException@Deprecated
public static void writeRawField(java.lang.String field,
BytesReference source,
XContentBuilder builder,
ToXContent.Params params)
throws java.io.IOException
#writeRawField(String, BytesReference, XContentType, XContentBuilder, Params) to avoid content type
auto-detectionXContentBuilder.rawField(String, org.elasticsearch.common.bytes.BytesReference).java.io.IOExceptionpublic static void writeRawField(java.lang.String field,
BytesReference source,
XContentType xContentType,
XContentBuilder builder,
ToXContent.Params params)
throws java.io.IOException
XContentBuilder.rawField(String, org.elasticsearch.common.bytes.BytesReference, XContentType).java.io.IOExceptionpublic static BytesReference toXContent(ToXContent toXContent, XContentType xContentType, boolean humanReadable) throws java.io.IOException
ToXContent object, using the provided
XContentType. Wraps the output into a new anonymous object according to the value returned
by the ToXContent.isFragment() method returns.java.io.IOExceptionpublic static BytesReference toXContent(ToXContent toXContent, XContentType xContentType, ToXContent.Params params, boolean humanReadable) throws java.io.IOException
ToXContent object, using the provided
XContentType. Wraps the output into a new anonymous object according to the value returned
by the ToXContent.isFragment() method returns.java.io.IOException