diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-30 11:29:46 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-30 11:29:46 +0000 |
commit | d30cb8d388a56ea1f02d87e3da3a1fcbacc639c8 (patch) | |
tree | a358a5b6969afc049308aab060ac0db454cdd46f /document/src/main | |
parent | 70915ed4ea7fe40bcacc2f2bf3b93f36ae79163d (diff) |
Header/body does not exist anymore. Deprecate and remove own internal usage.
Diffstat (limited to 'document/src/main')
5 files changed, 25 insertions, 24 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentType.java b/document/src/main/java/com/yahoo/document/DocumentType.java index f3ff6e4ed30..42ccca9f477 100755 --- a/document/src/main/java/com/yahoo/document/DocumentType.java +++ b/document/src/main/java/com/yahoo/document/DocumentType.java @@ -181,8 +181,7 @@ public class DocumentType extends StructuredDataType { if (isRegistered()) { throw new IllegalStateException("You cannot add fields to a document type that is already registered."); } - StructDataType struct = (field.isHeader() ? headerType : bodyType); - struct.addField(field); + headerType.addField(field); } // Do not use, public only for testing @@ -221,8 +220,8 @@ public class DocumentType extends StructuredDataType { if (isRegistered()) { throw new IllegalStateException("You cannot add fields to a document type that is already registered."); } - Field field = new Field(name, type, false); - bodyType.addField(field); + Field field = new Field(name, type); + headerType.addField(field); return field; } @@ -234,13 +233,9 @@ public class DocumentType extends StructuredDataType { * @return The field created * TODO Fix searchdefinition so that exception can be thrown if filed is already registerd */ + @Deprecated public Field addHeaderField(String name, DataType type) { - if (isRegistered()) { - throw new IllegalStateException("You cannot add fields to a document type that is already registered."); - } - Field field = new Field(name, type, true); - headerType.addField(field); - return field; + return addField(name, type); } /** diff --git a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java index 154c25880a9..5e698e980ff 100644 --- a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java +++ b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java @@ -180,9 +180,9 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub : manager.getDataType(field.datatype(), field.detailedtype()); if (field.id().size() == 1) { - type.addField(new Field(field.name(), field.id().get(0).id(), fieldType, true)); + type.addField(new Field(field.name(), field.id().get(0).id(), fieldType)); } else { - type.addField(new Field(field.name(), fieldType, true)); + type.addField(new Field(field.name(), fieldType)); } } manager.register(type); diff --git a/document/src/main/java/com/yahoo/document/Field.java b/document/src/main/java/com/yahoo/document/Field.java index 671c8c7f763..9be4036174c 100644 --- a/document/src/main/java/com/yahoo/document/Field.java +++ b/document/src/main/java/com/yahoo/document/Field.java @@ -21,7 +21,6 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab protected DataType dataType; protected int fieldId; - private boolean isHeader; private boolean forcedId; /** @@ -32,11 +31,14 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab * @param isHeader Whether this is a "header" field or a "content" field * (true = "header"). */ + @Deprecated public Field(String name, int id, DataType dataType, boolean isHeader) { + this(name, id, dataType); + } + public Field(String name, int id, DataType dataType) { super(name); this.fieldId = id; this.dataType = dataType; - this.isHeader = isHeader; this.forcedId = true; validateId(id, null); } @@ -55,8 +57,13 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab * (true = "header"). * @param owner the owning document (used to check for id collisions) */ + @Deprecated public Field(String name, DataType dataType, boolean isHeader, DocumentType owner) { - this(name, 0, dataType, isHeader); + this(name, dataType, owner); + } + + public Field(String name, DataType dataType, DocumentType owner) { + this(name, 0, dataType); this.fieldId = calculateIdV7(owner); this.forcedId = false; } @@ -69,8 +76,9 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab * @param isHeader Whether this is a "header" field or a "content" field * (true = "header"). */ + @Deprecated public Field(String name, DataType dataType, boolean isHeader) { - this(name, dataType, isHeader, null); + this(name, dataType); } /** @@ -80,7 +88,7 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab * @param dataType The datatype of the field */ public Field(String name, DataType dataType) { - this(name, dataType, true); + this(name, dataType, null); } /** @@ -89,7 +97,7 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab */ // TODO: Decide on one copy/clone idiom and do it for this and all it is calling public Field(String name, Field field) { - this(name, field.dataType, field.isHeader, null); + this(name, field.dataType, null); } public int compareTo(Object o) { @@ -196,14 +204,12 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab /** @deprecated this has no longer any semantic meaning as this is no longer an aspect with a field */ @Deprecated // TODO: Remove on Vespa 8 public boolean isHeader() { - return isHeader; + return true; } /** @deprecated this has no longer any semantic meaning as this is no longer an aspect with a field */ @Deprecated // TODO: Remove on Vespa 8 - public void setHeader(boolean header) { - this.isHeader = header; - } + public void setHeader(boolean header) { } /** Two fields are equal if they have the same name and the same data type */ @Override diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java index c2111edfd10..630f204c44d 100644 --- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java +++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java @@ -82,7 +82,7 @@ public class VespaDocumentSerializer6 extends BufferSerializer implements Docume } public void write(Document doc) { - write(new Field(doc.getDataType().getName(), 0, doc.getDataType(), true), doc); + write(new Field(doc.getDataType().getName(), 0, doc.getDataType()), doc); } @SuppressWarnings("deprecation") diff --git a/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java b/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java index 0d6b0cae926..5db98f26141 100644 --- a/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java +++ b/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java @@ -320,7 +320,7 @@ public final class XmlDocumentWriter implements DocumentWriter { buffer = new XmlStream(); buffer.setIndent(indent); optionalWrapperMarker.clear(); - write(new Field(document.getDataType().getName(), 0, document.getDataType(), true), document); + write(new Field(document.getDataType().getName(), 0, document.getDataType()), document); } @Override |