aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-10-31 23:02:45 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2018-10-31 23:02:45 +0100
commitfb6f2c5f01f615b16860b76ba7a39b5fa7d5518f (patch)
tree954fdf6ef08d341df4558273b9aa26a33af7fc63 /document/src/main/java/com/yahoo
parent3db4288215479f38f7db9c1ddeeceb69a8ff93e5 (diff)
Deprecating a whole lot of body/header related methods that should have been done a long time ago.
Diffstat (limited to 'document/src/main/java/com/yahoo')
-rw-r--r--document/src/main/java/com/yahoo/document/Document.java24
-rwxr-xr-xdocument/src/main/java/com/yahoo/document/DocumentType.java28
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java1
-rw-r--r--document/src/main/java/com/yahoo/document/Field.java13
-rw-r--r--document/src/main/java/com/yahoo/document/fieldset/BodyFields.java2
-rw-r--r--document/src/main/java/com/yahoo/document/fieldset/FieldSetRepo.java2
-rw-r--r--document/src/main/java/com/yahoo/document/fieldset/HeaderFields.java2
-rw-r--r--document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer42.java18
-rw-r--r--document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java1
9 files changed, 58 insertions, 33 deletions
diff --git a/document/src/main/java/com/yahoo/document/Document.java b/document/src/main/java/com/yahoo/document/Document.java
index 23beab7523e..55183f8fa70 100644
--- a/document/src/main/java/com/yahoo/document/Document.java
+++ b/document/src/main/java/com/yahoo/document/Document.java
@@ -99,7 +99,9 @@ public class Document extends StructuredFieldValue {
docId = id;
}
+ @Deprecated
public Struct getHeader() { return header; }
+ @Deprecated
public Struct getBody() { return body; }
@Override
@@ -116,8 +118,9 @@ public class Document extends StructuredFieldValue {
return doc;
}
+ @SuppressWarnings("deprecation")
private void setNewType(DocumentType type) {
- header = type.getHeaderType().createFieldValue();
+ header = type.getContentType().createFieldValue();
body = type.getBodyType().createFieldValue();
}
@@ -188,14 +191,15 @@ public class Document extends StructuredFieldValue {
@Override
public FieldValue getFieldValue(Field field) {
- if (field.isHeader()) {
- return header.getFieldValue(field);
- } else {
- return body.getFieldValue(field);
+ FieldValue fv = header.getFieldValue(field);
+ if (fv == null) {
+ fv = body.getFieldValue(field);
}
+ return fv;
}
@Override
+ @SuppressWarnings("deprecation")
protected void doSetFieldValue(Field field, FieldValue value) {
if (field.isHeader()) {
header.setFieldValue(field, value);
@@ -206,11 +210,11 @@ public class Document extends StructuredFieldValue {
@Override
public FieldValue removeFieldValue(Field field) {
- if (field.isHeader()) {
- return header.removeFieldValue(field);
- } else {
- return body.removeFieldValue(field);
+ FieldValue removed = header.removeFieldValue(field);
+ if (removed == null) {
+ removed = body.removeFieldValue(field);
}
+ return removed;
}
@Override
@@ -338,6 +342,7 @@ public class Document extends StructuredFieldValue {
}
@SuppressWarnings("deprecation")
+ @Deprecated
public void serializeHeader(Serializer data) throws SerializationException {
if (data instanceof DocumentWriter) {
if (data instanceof com.yahoo.document.serialization.VespaDocumentSerializer42) {
@@ -353,6 +358,7 @@ public class Document extends StructuredFieldValue {
}
}
+ @Deprecated
public void serializeBody(Serializer data) throws SerializationException {
if (getBody().getFieldCount() > 0) {
if (data instanceof FieldWriter) {
diff --git a/document/src/main/java/com/yahoo/document/DocumentType.java b/document/src/main/java/com/yahoo/document/DocumentType.java
index 61e9a9ba83f..f2a501100f2 100755
--- a/document/src/main/java/com/yahoo/document/DocumentType.java
+++ b/document/src/main/java/com/yahoo/document/DocumentType.java
@@ -9,7 +9,17 @@ import com.yahoo.vespa.objects.Ids;
import com.yahoo.vespa.objects.ObjectVisitor;
import com.yahoo.vespa.objects.Serializer;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+
/**
* <p>A document definition is a list of fields. Documents may inherit other documents,
@@ -19,12 +29,13 @@ import java.util.*;
* @author <a href="mailto:thomasg@yahoo-inc.com">Thomas Gundersen</a>
* @author bratseth
*/
+// TODO Vespa 7 Remove header/body concept
public class DocumentType extends StructuredDataType {
public static final int classId = registerClass(Ids.document + 58, DocumentType.class);
private StructDataType headerType;
private StructDataType bodyType;
- private List<DocumentType> inherits = new ArrayList<DocumentType>(1);
+ private List<DocumentType> inherits = new ArrayList<>(1);
/**
* Creates a new document type and registers it with the document type manager.
@@ -89,15 +100,23 @@ public class DocumentType extends StructuredDataType {
return false;
}
- public StructDataType getHeaderType() {
+ public StructDataType getContentType() {
return headerType;
}
+ // Use getContentType instead
+ @Deprecated
+ public StructDataType getHeaderType() {
+ return getContentType();
+ }
+
+ @Deprecated
public StructDataType getBodyType() {
return bodyType;
}
@Override
+ @SuppressWarnings("deprecation")
protected void register(DocumentTypeManager manager, List<DataType> seenTypes) {
seenTypes.add(this);
for (DocumentType type : getInheritedTypes()) {
@@ -148,6 +167,7 @@ public class DocumentType extends StructuredDataType {
*
* @param field the field to add
*/
+ @SuppressWarnings("deprecation")
public void addField(Field field) {
if (isRegistered()) {
throw new IllegalStateException("You cannot add fields to a document type that is already registered.");
@@ -397,7 +417,7 @@ public class DocumentType extends StructuredDataType {
* @return an unmodifiable snapshot of the fields in this type
*/
public Set<Field> fieldSet() {
- Map<String, Field> map = new LinkedHashMap<String, Field>();
+ Map<String, Field> map = new LinkedHashMap<>();
for (Field field : getFields()) { // Uniqify on field name
map.put(field.getName(), field);
}
diff --git a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
index 7678360ea30..be5c6856ee5 100644
--- a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
+++ b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
@@ -134,6 +134,7 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
manager.register(type);
}
+ @SuppressWarnings("deprecation")
private static void registerDocumentType(DocumentTypeManager manager, DocumentmanagerConfig.Datatype.Documenttype doc) {
StructDataType header = (StructDataType) manager.getDataType(doc.headerstruct(), "");
StructDataType body = (StructDataType) manager.getDataType(doc.bodystruct(), "");
diff --git a/document/src/main/java/com/yahoo/document/Field.java b/document/src/main/java/com/yahoo/document/Field.java
index 4098c85b3e3..16ce69453ab 100644
--- a/document/src/main/java/com/yahoo/document/Field.java
+++ b/document/src/main/java/com/yahoo/document/Field.java
@@ -16,6 +16,7 @@ import java.io.Serializable;
* @author Thomas Gundersen
* @author bratseth
*/
+//TODO Vespa 7 Remove deprecated methods.
public class Field extends FieldBase implements FieldSet, Comparable, Serializable {
protected DataType dataType;
@@ -214,12 +215,20 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab
return forcedId;
}
- /** @return Returns true if this field should be a part of "header" serializations. */
+ /**
+ * NB: Has no longer any semantic meaning as this is no longer an aspect with a field.
+ * @return Returns true if this field should be a part of "header" serializations.
+ */
+ @Deprecated
public boolean isHeader() {
return isHeader;
}
- /** Sets whether this is a header field */
+ /**
+ * NB: Has no longer any semantic meaning as this is no longer an aspect with a field.
+ * Sets whether this is a header field
+ */
+ @Deprecated
public void setHeader(boolean header) {
this.isHeader = header;
}
diff --git a/document/src/main/java/com/yahoo/document/fieldset/BodyFields.java b/document/src/main/java/com/yahoo/document/fieldset/BodyFields.java
index 912ec798fdb..72c48684b86 100644
--- a/document/src/main/java/com/yahoo/document/fieldset/BodyFields.java
+++ b/document/src/main/java/com/yahoo/document/fieldset/BodyFields.java
@@ -10,6 +10,8 @@ import com.yahoo.document.Field;
* Time: 3:18 PM
* To change this template use File | Settings | File Templates.
*/
+//TODO Vespa 7 Remove
+@Deprecated
public class BodyFields implements FieldSet {
@Override
public boolean contains(FieldSet o) {
diff --git a/document/src/main/java/com/yahoo/document/fieldset/FieldSetRepo.java b/document/src/main/java/com/yahoo/document/fieldset/FieldSetRepo.java
index 38ea190b0d4..a7035439903 100644
--- a/document/src/main/java/com/yahoo/document/fieldset/FieldSetRepo.java
+++ b/document/src/main/java/com/yahoo/document/fieldset/FieldSetRepo.java
@@ -15,6 +15,7 @@ import java.util.*;
*/
public class FieldSetRepo {
+ @SuppressWarnings("deprecation")
FieldSet parseSpecialValues(String name)
{
if (name.equals("[id]")) { return new DocIdOnly(); }
@@ -73,6 +74,7 @@ public class FieldSetRepo {
return parseFieldCollection(docMan, type, fields);
}
+ @SuppressWarnings("deprecation")
public String serialize(FieldSet fieldSet) {
if (fieldSet instanceof Field) {
return ((Field)fieldSet).getName();
diff --git a/document/src/main/java/com/yahoo/document/fieldset/HeaderFields.java b/document/src/main/java/com/yahoo/document/fieldset/HeaderFields.java
index e3b8befa226..ee55bd88faf 100644
--- a/document/src/main/java/com/yahoo/document/fieldset/HeaderFields.java
+++ b/document/src/main/java/com/yahoo/document/fieldset/HeaderFields.java
@@ -10,6 +10,8 @@ import com.yahoo.document.Field;
* Time: 3:18 PM
* To change this template use File | Settings | File Templates.
*/
+//TODO Vespa 7 Remove
+@Deprecated
public class HeaderFields implements FieldSet {
@Override
public boolean contains(FieldSet o) {
diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer42.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer42.java
index c3bf9303529..460d35ed266 100644
--- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer42.java
+++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer42.java
@@ -71,8 +71,6 @@ import static com.yahoo.text.Utf8.calculateBytePositions;
// When removing: Move content into VespaDocumentSerializerHead
public class VespaDocumentSerializer42 extends BufferSerializer implements DocumentSerializer {
- private final Compressor compressor = new Compressor();
- private final static Logger log = Logger.getLogger(VespaDocumentSerializer42.class.getName());
private boolean headerOnly;
private int spanNodeCounter = -1;
private int[] bytePositions;
@@ -81,14 +79,6 @@ public class VespaDocumentSerializer42 extends BufferSerializer implements Docum
super(buf);
}
- VespaDocumentSerializer42(ByteBuffer buf) {
- super(buf);
- }
-
- VespaDocumentSerializer42(byte[] buf) {
- super(buf);
- }
-
VespaDocumentSerializer42() {
super();
}
@@ -460,14 +450,6 @@ public class VespaDocumentSerializer42 extends BufferSerializer implements Docum
putShort(null, (short) 0); // Used to hold the version. Is now always 0.
}
-
- private static void serializeAttributeString(GrowableByteBuffer data, String input) {
- byte[] inputBytes = createUTF8CharArray(input);
- data.put((byte) (inputBytes.length));
- data.put(inputBytes);
- data.put((byte) 0);
- }
-
public void write(Annotation annotation) {
buf.putInt(annotation.getType().getId()); //name hash
diff --git a/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java b/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java
index f2f7cc88d00..941dbc8d406 100644
--- a/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java
+++ b/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java
@@ -47,6 +47,7 @@ public class XmlSerializationHelper {
xml.addContent(b.toString());
}
+ @SuppressWarnings("deprecation")
public static void printDocumentXml(Document doc, XmlStream xml) {
xml.addAttribute("documenttype", doc.getDataType().getName());
xml.addAttribute("documentid", doc.getId());