summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java')
-rw-r--r--core/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java b/core/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java
index 0cafc50bbe..a8a983ecde 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/SourceToParse.java
@@ -23,15 +23,18 @@ import java.util.Objects;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentType;
public class SourceToParse {
- public static SourceToParse source(String index, String type, String id, BytesReference source) {
- return source(Origin.PRIMARY, index, type, id, source);
+ public static SourceToParse source(String index, String type, String id, BytesReference source, XContentType contentType) {
+ return source(Origin.PRIMARY, index, type, id, source, contentType);
}
- public static SourceToParse source(Origin origin, String index, String type, String id, BytesReference source) {
- return new SourceToParse(origin, index, type, id, source);
+ public static SourceToParse source(Origin origin, String index, String type, String id, BytesReference source,
+ XContentType contentType) {
+ return new SourceToParse(origin, index, type, id, source, contentType);
}
private final Origin origin;
@@ -48,14 +51,17 @@ public class SourceToParse {
private String parentId;
- private SourceToParse(Origin origin, String index, String type, String id, BytesReference source) {
+ private XContentType xContentType;
+
+ private SourceToParse(Origin origin, String index, String type, String id, BytesReference source, XContentType xContentType) {
this.origin = Objects.requireNonNull(origin);
this.index = Objects.requireNonNull(index);
this.type = Objects.requireNonNull(type);
this.id = Objects.requireNonNull(id);
// we always convert back to byte array, since we store it and Field only supports bytes..
// so, we might as well do it here, and improve the performance of working with direct byte arrays
- this.source = new BytesArray(source.toBytesRef());
+ this.source = new BytesArray(Objects.requireNonNull(source).toBytesRef());
+ this.xContentType = Objects.requireNonNull(xContentType);
}
public Origin origin() {
@@ -91,6 +97,10 @@ public class SourceToParse {
return this.routing;
}
+ public XContentType getXContentType() {
+ return this.xContentType;
+ }
+
public SourceToParse routing(String routing) {
this.routing = routing;
return this;