public class XContentHelper extends Object
Constructor and Description |
---|
XContentHelper() |
Modifier and Type | Method and Description |
---|---|
static String |
convertToJson(byte[] data,
int offset,
int length,
boolean reformatJson) |
static String |
convertToJson(byte[] data,
int offset,
int length,
boolean reformatJson,
boolean prettyPrint) |
static String |
convertToJson(BytesReference bytes,
boolean reformatJson) |
static String |
convertToJson(BytesReference bytes,
boolean reformatJson,
boolean prettyPrint) |
static Tuple<XContentType,Map<String,Object>> |
convertToMap(BytesReference bytes,
boolean ordered) |
static void |
copyCurrentEvent(XContentGenerator generator,
XContentParser parser) |
static void |
copyCurrentStructure(XContentGenerator generator,
XContentParser parser) |
static XContentParser |
createParser(BytesReference bytes) |
static void |
mergeDefaults(Map<String,Object> content,
Map<String,Object> defaults)
Merges the defaults provided as the second parameter into the content of the first.
|
static String |
toString(ToXContent toXContent)
Writes serialized toXContent to pretty-printed JSON string.
|
static String |
toString(ToXContent toXContent,
ToXContent.Params params)
Writes serialized toXContent to pretty-printed JSON string.
|
static boolean |
update(Map<String,Object> source,
Map<String,Object> changes,
boolean checkUpdatesAreUnequal)
Updates the provided changes into the source.
|
static void |
writeRawField(String field,
BytesReference source,
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) . |
public static XContentParser createParser(BytesReference bytes) throws IOException
IOException
public static Tuple<XContentType,Map<String,Object>> convertToMap(BytesReference bytes, boolean ordered) throws ElasticsearchParseException
ElasticsearchParseException
public static String convertToJson(BytesReference bytes, boolean reformatJson) throws IOException
IOException
public static String convertToJson(BytesReference bytes, boolean reformatJson, boolean prettyPrint) throws IOException
IOException
public static String convertToJson(byte[] data, int offset, int length, boolean reformatJson) throws IOException
IOException
public static String convertToJson(byte[] data, int offset, int length, boolean reformatJson, boolean prettyPrint) throws IOException
IOException
public static String toString(ToXContent toXContent)
toXContent
- object to be pretty printedpublic static String toString(ToXContent toXContent, ToXContent.Params params)
toXContent
- object to be pretty printedparams
- serialization parameterspublic static boolean update(Map<String,Object> source, Map<String,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(Map<String,Object> content, Map<String,Object> defaults)
public static void copyCurrentStructure(XContentGenerator generator, XContentParser parser) throws IOException
IOException
public static void copyCurrentEvent(XContentGenerator generator, XContentParser parser) throws IOException
IOException
public static void writeRawField(String field, BytesReference source, XContentBuilder builder, ToXContent.Params params) throws IOException
XContentBuilder.rawField(String, org.elasticsearch.common.bytes.BytesReference)
.IOException
Copyright © 2009–2017. All rights reserved.