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
|
static String |
convertToJson(BytesReference
|
static Tuple |
convertToMap(byte[] data, boolean ordered)
|
static Tuple |
convertToMap(byte[] data, int offset, int length, boolean ordered)
|
static Tuple |
convertToMap(BytesReference
|
static void |
copyCurrentEvent(XContentGenerator
|
static void |
copyCurrentStructure(XContentGenerator
|
static XContentParser |
createParser(byte[] data, int offset, int length)
|
static XContentParser |
createParser(BytesReference
|
static void |
mergeDefaults(Map
Merges the defaults provided as the second parameter into the content of the first.
|
static String |
toString(ToXContent
Writes serialized toXContent to pretty-printed JSON string.
|
static String |
toString(ToXContent
Writes serialized toXContent to pretty-printed JSON string.
|
static boolean |
update(Map
Updates the provided changes into the source.
|
static void |
writeDirect(BytesReference
Directly writes the source to the output builder
|
static void |
writeRawField(String
Writes a "raw" (bytes) field, handling cases where the bytes are compressed, and tries to optimize writing using
XContentBuilder.
|
public static XContentParsercreateParser(BytesReference bytes) throws IOException
IOException
public static XContentParsercreateParser(byte[] data, int offset, int length) throws IOException
IOException
public static Tuple<XContentType ,Map <String ,Object >> convertToMap(BytesReference bytes, boolean ordered) throws ElasticsearchParseException
ElasticsearchParseException
public static Tuple<XContentType ,Map <String ,Object >> convertToMap(byte[] data, boolean ordered) throws ElasticsearchParseException
ElasticsearchParseException
public static Tuple<XContentType ,Map <String ,Object >> convertToMap(byte[] data, int offset, int length, boolean ordered) throws ElasticsearchParseException
ElasticsearchParseException
public static StringconvertToJson(BytesReference bytes, boolean reformatJson) throws IOException
IOException
public static StringconvertToJson(BytesReference bytes, boolean reformatJson, boolean prettyPrint) throws IOException
IOException
public static StringconvertToJson(byte[] data, int offset, int length, boolean reformatJson) throws IOException
IOException
public static StringconvertToJson(byte[] data, int offset, int length, boolean reformatJson, boolean prettyPrint) throws IOException
IOException
public static StringtoString(ToXContent toXContent)
toXContent - object to be pretty printed
public static StringtoString(ToXContent toXContent, ToXContent .Params params)
toXContent - object to be pretty printed
params - serialization parameters
public static boolean update(Map<String ,Object > source, Map <String ,Object > changes, boolean checkUpdatesAreUnequal)
source - the original map to be updated
changes - the changes to update into updated
checkUpdatesAreUnequal - 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(XContentGeneratorgenerator, XContentParser parser) throws IOException
IOException
public static void copyCurrentEvent(XContentGeneratorgenerator, XContentParser parser) throws IOException
IOException
public static void writeDirect(BytesReferencesource, XContentBuilder rawBuilder, ToXContent .Params params) throws IOException
IOException
public static void writeRawField(Stringfield, BytesReference source, XContentBuilder builder, ToXContent .Params params) throws IOException
XContentBuilder.rawField(String, org.elasticsearch.common.bytes.BytesReference) .
IOException