From 75ab63c8dea02c4e8148fb7e79730d163eb6647e Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 27 Jan 2023 14:07:45 +0100 Subject: Deprecate xml methods --- .../com/yahoo/docproc/proxy/ProxyDocument.java | 3 + document/abi-spec.json | 48 --- .../src/main/java/com/yahoo/document/Document.java | 3 + .../java/com/yahoo/document/PositionDataType.java | 1 + .../document/annotation/AnnotationReference.java | 1 + .../java/com/yahoo/document/datatypes/Array.java | 1 + .../yahoo/document/datatypes/BoolFieldValue.java | 1 + .../yahoo/document/datatypes/ByteFieldValue.java | 1 + .../yahoo/document/datatypes/DoubleFieldValue.java | 1 + .../com/yahoo/document/datatypes/FieldValue.java | 2 + .../document/datatypes/Float16FieldValue.java | 1 + .../yahoo/document/datatypes/FloatFieldValue.java | 1 + .../document/datatypes/IntegerFieldValue.java | 1 + .../yahoo/document/datatypes/LongFieldValue.java | 1 + .../yahoo/document/datatypes/MapFieldValue.java | 1 + .../document/datatypes/PredicateFieldValue.java | 1 + .../java/com/yahoo/document/datatypes/Raw.java | 1 + .../document/datatypes/ReferenceFieldValue.java | 1 + .../yahoo/document/datatypes/StringFieldValue.java | 1 + .../java/com/yahoo/document/datatypes/Struct.java | 1 + .../yahoo/document/datatypes/TensorFieldValue.java | 1 + .../com/yahoo/document/datatypes/WeightedSet.java | 1 + .../document/serialization/XmlDocumentWriter.java | 339 --------------------- .../serialization/XmlSerializationHelper.java | 2 + .../yahoo/document/serialization/XmlStream.java | 1 + .../java/com/yahoo/document/DocumentTestCase.java | 18 +- .../document/annotation/Bug6394548TestCase.java | 2 + .../datatypes/PredicateFieldValueTest.java | 3 + .../yahoo/document/datatypes/StructTestCase.java | 1 + .../serialization/XmlDocumentWriterTestCase.java | 29 -- .../document/serialization/XmlStreamTestCase.java | 4 +- .../expressions/UnresolvedFieldValue.java | 1 + .../FieldValueConverterTestCase.java | 1 + .../expressions/IfThenTestCase.java | 1 + .../expressions/UnresolvedDataTypeTestCase.java | 1 + .../expressions/UnresolvedFieldValueTestCase.java | 1 + .../com/yahoo/dummyreceiver/DummyReceiver.java | 1 + .../java/com/yahoo/vespaget/DocumentRetriever.java | 1 + .../com/yahoo/vespavisit/StdOutVisitorHandler.java | 1 + .../main/java/com/yahoo/vespavisit/VdsVisit.java | 2 +- 40 files changed, 49 insertions(+), 434 deletions(-) delete mode 100644 document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java delete mode 100644 document/src/test/java/com/yahoo/document/serialization/XmlDocumentWriterTestCase.java diff --git a/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocument.java b/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocument.java index 975d396a5cb..5ef97afec55 100644 --- a/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocument.java +++ b/docproc/src/main/java/com/yahoo/docproc/proxy/ProxyDocument.java @@ -255,16 +255,19 @@ public class ProxyDocument extends Document implements DocumentOperationWrapper } @Override + @Deprecated public String toXML(String indent) { return doc.toXML(indent); } @Override + @Deprecated public String toXml() { return doc.toXml(); } @Override + @Deprecated public void printXml(XmlStream xml) { doc.printXml(xml); } diff --git a/document/abi-spec.json b/document/abi-spec.json index 1ab6c91dbf9..5f520f1a4d1 100644 --- a/document/abi-spec.json +++ b/document/abi-spec.json @@ -3138,54 +3138,6 @@ ], "fields" : [ ] }, - "com.yahoo.document.serialization.XmlDocumentWriter" : { - "superClass" : "java.lang.Object", - "interfaces" : [ - "com.yahoo.document.serialization.DocumentWriter" - ], - "attributes" : [ - "public", - "final" - ], - "methods" : [ - "public static com.yahoo.document.serialization.XmlDocumentWriter createWriter(java.lang.String)", - "public void ()", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.FieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.Document)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.Array)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.MapFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.ByteFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.BoolFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.CollectionFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.DoubleFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.FloatFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.IntegerFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.LongFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.Raw)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.PredicateFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.StringFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.TensorFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.ReferenceFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.Struct)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.StructuredFieldValue)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.datatypes.WeightedSet)", - "public void write(com.yahoo.vespa.objects.FieldBase, com.yahoo.document.annotation.AnnotationReference)", - "public com.yahoo.vespa.objects.Serializer putByte(com.yahoo.vespa.objects.FieldBase, byte)", - "public com.yahoo.vespa.objects.Serializer putShort(com.yahoo.vespa.objects.FieldBase, short)", - "public com.yahoo.vespa.objects.Serializer putInt(com.yahoo.vespa.objects.FieldBase, int)", - "public com.yahoo.vespa.objects.Serializer putLong(com.yahoo.vespa.objects.FieldBase, long)", - "public com.yahoo.vespa.objects.Serializer putFloat(com.yahoo.vespa.objects.FieldBase, float)", - "public com.yahoo.vespa.objects.Serializer putDouble(com.yahoo.vespa.objects.FieldBase, double)", - "public com.yahoo.vespa.objects.Serializer put(com.yahoo.vespa.objects.FieldBase, byte[])", - "public com.yahoo.vespa.objects.Serializer put(com.yahoo.vespa.objects.FieldBase, java.nio.ByteBuffer)", - "public com.yahoo.vespa.objects.Serializer put(com.yahoo.vespa.objects.FieldBase, java.lang.String)", - "public void write(com.yahoo.document.Document)", - "public void write(com.yahoo.document.DocumentId)", - "public void write(com.yahoo.document.DocumentType)", - "public java.lang.String lastRendered()" - ], - "fields" : [ ] - }, "com.yahoo.document.serialization.XmlSerializationHelper" : { "superClass" : "java.lang.Object", "interfaces" : [ ], diff --git a/document/src/main/java/com/yahoo/document/Document.java b/document/src/main/java/com/yahoo/document/Document.java index 3dc628e0a90..ac789bc681d 100644 --- a/document/src/main/java/com/yahoo/document/Document.java +++ b/document/src/main/java/com/yahoo/document/Document.java @@ -204,6 +204,7 @@ public class Document extends StructuredFieldValue { return "document '" + docId + "' of type '" + getDataType().getName() + "'"; } + @Deprecated public String toXML(String indent) { XmlStream xml = new XmlStream(); xml.setIndent(indent); @@ -218,10 +219,12 @@ public class Document extends StructuredFieldValue { * within a <document></document> tag. * @return XML representation of document */ + @Deprecated public String toXml() { return toXML(" "); } + @Deprecated public void printXml(XmlStream xml) { XmlSerializationHelper.printDocumentXml(this, xml); } diff --git a/document/src/main/java/com/yahoo/document/PositionDataType.java b/document/src/main/java/com/yahoo/document/PositionDataType.java index d4160fc58c7..c442145a74e 100644 --- a/document/src/main/java/com/yahoo/document/PositionDataType.java +++ b/document/src/main/java/com/yahoo/document/PositionDataType.java @@ -53,6 +53,7 @@ public final class PositionDataType { return buf.toString(); } + @Deprecated public static void renderXml(Struct pos, XmlStream target) { target.addContent(renderAsString(pos)); } diff --git a/document/src/main/java/com/yahoo/document/annotation/AnnotationReference.java b/document/src/main/java/com/yahoo/document/annotation/AnnotationReference.java index cb8a7a6dd0a..924f401f8be 100644 --- a/document/src/main/java/com/yahoo/document/annotation/AnnotationReference.java +++ b/document/src/main/java/com/yahoo/document/annotation/AnnotationReference.java @@ -122,6 +122,7 @@ public class AnnotationReference extends FieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { // TODO: Implement AnnotationReference.printXml() } diff --git a/document/src/main/java/com/yahoo/document/datatypes/Array.java b/document/src/main/java/com/yahoo/document/datatypes/Array.java index dba1c0783cf..f1d1255916c 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/Array.java +++ b/document/src/main/java/com/yahoo/document/datatypes/Array.java @@ -112,6 +112,7 @@ public final class Array extends CollectionFieldValue i } @Override + @Deprecated public void printXml(XmlStream xml) { XmlSerializationHelper.printArrayXml(this, xml); } diff --git a/document/src/main/java/com/yahoo/document/datatypes/BoolFieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/BoolFieldValue.java index 962ed6b1817..199ca199667 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/BoolFieldValue.java +++ b/document/src/main/java/com/yahoo/document/datatypes/BoolFieldValue.java @@ -76,6 +76,7 @@ public class BoolFieldValue extends FieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { XmlSerializationHelper.printBoolXml(this, xml); } diff --git a/document/src/main/java/com/yahoo/document/datatypes/ByteFieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/ByteFieldValue.java index bf010b4715d..ec455f90f06 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/ByteFieldValue.java +++ b/document/src/main/java/com/yahoo/document/datatypes/ByteFieldValue.java @@ -93,6 +93,7 @@ public class ByteFieldValue extends NumericFieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { XmlSerializationHelper.printByteXml(this, xml); } diff --git a/document/src/main/java/com/yahoo/document/datatypes/DoubleFieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/DoubleFieldValue.java index 55dfff2a954..2fbf1808a75 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/DoubleFieldValue.java +++ b/document/src/main/java/com/yahoo/document/datatypes/DoubleFieldValue.java @@ -88,6 +88,7 @@ public final class DoubleFieldValue extends NumericFieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { XmlSerializationHelper.printDoubleXml(this, xml); } diff --git a/document/src/main/java/com/yahoo/document/datatypes/FieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/FieldValue.java index 493dd964b9e..d43fed19005 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/FieldValue.java +++ b/document/src/main/java/com/yahoo/document/datatypes/FieldValue.java @@ -37,6 +37,7 @@ public abstract class FieldValue extends Identifiable implements Comparable extends C } @Override + @Deprecated public void printXml(XmlStream xml) { XmlSerializationHelper.printMapXml(this, xml); } diff --git a/document/src/main/java/com/yahoo/document/datatypes/PredicateFieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/PredicateFieldValue.java index aba5e51f723..dc62a5f413d 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/PredicateFieldValue.java +++ b/document/src/main/java/com/yahoo/document/datatypes/PredicateFieldValue.java @@ -45,6 +45,7 @@ public class PredicateFieldValue extends FieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { if (predicate == null) { return; diff --git a/document/src/main/java/com/yahoo/document/datatypes/Raw.java b/document/src/main/java/com/yahoo/document/datatypes/Raw.java index f6efc626f06..adae64f3874 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/Raw.java +++ b/document/src/main/java/com/yahoo/document/datatypes/Raw.java @@ -100,6 +100,7 @@ public final class Raw extends FieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { XmlSerializationHelper.printRawXml(this, xml); } diff --git a/document/src/main/java/com/yahoo/document/datatypes/ReferenceFieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/ReferenceFieldValue.java index ebc39b14eb1..75ae0164b65 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/ReferenceFieldValue.java +++ b/document/src/main/java/com/yahoo/document/datatypes/ReferenceFieldValue.java @@ -88,6 +88,7 @@ public class ReferenceFieldValue extends FieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { } @Override diff --git a/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java index 6133c9ca0ad..6e999bb4041 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java +++ b/document/src/main/java/com/yahoo/document/datatypes/StringFieldValue.java @@ -218,6 +218,7 @@ public class StringFieldValue extends FieldValue { * @param xml the stream to print to */ @Override + @Deprecated public void printXml(XmlStream xml) { XmlSerializationHelper.printStringXml(this, xml); //TODO: add spanTree printing diff --git a/document/src/main/java/com/yahoo/document/datatypes/Struct.java b/document/src/main/java/com/yahoo/document/datatypes/Struct.java index d522e8cda44..11d5db06819 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/Struct.java +++ b/document/src/main/java/com/yahoo/document/datatypes/Struct.java @@ -92,6 +92,7 @@ public class Struct extends StructuredFieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { if (getDataType().equals(PositionDataType.INSTANCE)) { try { diff --git a/document/src/main/java/com/yahoo/document/datatypes/TensorFieldValue.java b/document/src/main/java/com/yahoo/document/datatypes/TensorFieldValue.java index 105739da508..2dab9e97246 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/TensorFieldValue.java +++ b/document/src/main/java/com/yahoo/document/datatypes/TensorFieldValue.java @@ -88,6 +88,7 @@ public class TensorFieldValue extends FieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { // TODO (geirst) } diff --git a/document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java b/document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java index 583c68d631b..08c151b2d51 100644 --- a/document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java +++ b/document/src/main/java/com/yahoo/document/datatypes/WeightedSet.java @@ -91,6 +91,7 @@ public final class WeightedSet extends CollectionFieldValu @Override + @Deprecated public void printXml(XmlStream xml) { XmlSerializationHelper.printWeightedSetXml(this, xml); } diff --git a/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java b/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java deleted file mode 100644 index aeb4bbe79b1..00000000000 --- a/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java +++ /dev/null @@ -1,339 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.document.serialization; - -import com.yahoo.document.Document; -import com.yahoo.document.DocumentId; -import com.yahoo.document.DocumentType; -import com.yahoo.document.Field; -import com.yahoo.document.annotation.AnnotationReference; -import com.yahoo.document.datatypes.Array; -import com.yahoo.document.datatypes.BoolFieldValue; -import com.yahoo.document.datatypes.ByteFieldValue; -import com.yahoo.document.datatypes.CollectionFieldValue; -import com.yahoo.document.datatypes.DoubleFieldValue; -import com.yahoo.document.datatypes.FieldValue; -import com.yahoo.document.datatypes.FloatFieldValue; -import com.yahoo.document.datatypes.IntegerFieldValue; -import com.yahoo.document.datatypes.LongFieldValue; -import com.yahoo.document.datatypes.MapFieldValue; -import com.yahoo.document.datatypes.PredicateFieldValue; -import com.yahoo.document.datatypes.Raw; -import com.yahoo.document.datatypes.ReferenceFieldValue; -import com.yahoo.document.datatypes.StringFieldValue; -import com.yahoo.document.datatypes.Struct; -import com.yahoo.document.datatypes.StructuredFieldValue; -import com.yahoo.document.datatypes.TensorFieldValue; -import com.yahoo.document.datatypes.WeightedSet; -import com.yahoo.vespa.objects.FieldBase; -import com.yahoo.vespa.objects.Serializer; - -import java.nio.ByteBuffer; -import java.util.ArrayDeque; -import java.util.Deque; -import java.util.Iterator; -import java.util.Map; - -// TODO: Just inline all use of XmlSerializationHelper when the toXml methods in FieldValue subclasses are to be removed -// TODO: More cleanup, the put() methods generate a lot of superfluous objects (write should call put, not the other way around) -// TODO: remove pingpong between XmlSerializationHelper and FieldValue, this will go away when the toXml methods go away -/** - * Render a Document instance as XML. - * - * @author Steinar Knutsen - */ -public final class XmlDocumentWriter implements DocumentWriter { - - private final String indent; - private XmlStream buffer; - private final Deque optionalWrapperMarker = new ArrayDeque<>(); - - public static XmlDocumentWriter createWriter(String indent) { - return new XmlDocumentWriter(indent); - } - - public XmlDocumentWriter() { - this(" "); - } - - private XmlDocumentWriter(String indent) { - this.indent = indent; - } - - // this method is silly, what is the intended way of doing this? - @Override - public void write(FieldBase field, FieldValue value) { - Class valueType = value.getClass(); - if (valueType == AnnotationReference.class) { - write(field, (AnnotationReference) value); - } else if (valueType == Array.class) { - write(field, (Array) value); - } else if (valueType == WeightedSet.class) { - write(field, (WeightedSet) value); - } else if (valueType == Document.class) { - write(field, (Document) value); - } else if (valueType == Struct.class) { - write(field, (Struct) value); - } else if (valueType == ByteFieldValue.class) { - write(field, (ByteFieldValue) value); - } else if (valueType == DoubleFieldValue.class) { - write(field, (DoubleFieldValue) value); - } else if (valueType == FloatFieldValue.class) { - write(field, (FloatFieldValue) value); - } else if (valueType == IntegerFieldValue.class) { - write(field, (IntegerFieldValue) value); - } else if (valueType == LongFieldValue.class) { - write(field, (LongFieldValue) value); - } else if (valueType == Raw.class) { - write(field, (Raw) value); - } else if (valueType == PredicateFieldValue.class) { - write(field, (PredicateFieldValue) value); - } else if (valueType == StringFieldValue.class) { - write(field, (StringFieldValue) value); - } else { - throw new UnsupportedOperationException("Cannot serialize a " - + valueType.getName()); - } - } - - @Override - public void write(FieldBase field, Document value) { - buffer.beginTag("document"); - buffer.addAttribute("documenttype", value.getDataType().getName()); - buffer.addAttribute("documentid", value.getId()); - final java.lang.Long lastModified = value.getLastModified(); - if (lastModified != null) { - buffer.addAttribute("lastmodifiedtime", lastModified); - } - StructuredFieldValue asStructured = value; - write(null, asStructured); - - buffer.endTag(); - } - - @Override - public void write(FieldBase field, Array value) { - buffer.beginTag(field.getName()); - XmlSerializationHelper.printArrayXml(value, buffer); - buffer.endTag(); - } - - private void singleValueTag(FieldBase field, FieldValue value) { - buffer.beginTag(field.getName()); - value.printXml(buffer); - buffer.endTag(); - } - - @Override - public void write(FieldBase field, MapFieldValue map) { - // TODO Auto-generated method stub - buffer.beginTag(field.getName()); - XmlSerializationHelper.printMapXml(map, buffer); - buffer.endTag(); - } - - @Override - public void write(FieldBase field, ByteFieldValue value) { - singleValueTag(field, value); - } - - @Override - public void write(FieldBase field, BoolFieldValue value) { - singleValueTag(field, value); - } - - @Override - public void write(FieldBase field, - CollectionFieldValue value) { - buffer.beginTag(field.getName()); - for (@SuppressWarnings("unchecked") - Iterator i = (Iterator) value.iterator(); - i.hasNext();) { - buffer.beginTag("item"); - i.next().printXml(buffer); - buffer.endTag(); - } - buffer.endTag(); - } - - @Override - public void write(FieldBase field, DoubleFieldValue value) { - singleValueTag(field, value); - } - - @Override - public void write(FieldBase field, FloatFieldValue value) { - singleValueTag(field, value); - } - - @Override - public void write(FieldBase field, IntegerFieldValue value) { - singleValueTag(field, value); - } - - @Override - public void write(FieldBase field, LongFieldValue value) { - singleValueTag(field, value); - } - - @Override - public void write(FieldBase field, Raw value) { - buffer.beginTag(field.getName()); - XmlSerializationHelper.printRawXml(value, buffer); - buffer.endTag(); - } - - @Override - public void write(FieldBase field, PredicateFieldValue value) { - singleValueTag(field, value); - } - - @Override - public void write(FieldBase field, StringFieldValue value) { - buffer.beginTag(field.getName()); - XmlSerializationHelper.printStringXml(value, buffer); - buffer.endTag(); - } - - @Override - public void write(FieldBase field, TensorFieldValue value) { - throw new IllegalArgumentException("write() for tensor field value not implemented yet"); - } - - @Override - public void write(FieldBase field, ReferenceFieldValue value) { - throw new IllegalArgumentException("write() for reference field value not implemented yet"); - } - - private void optionalWrapperStart(FieldBase field) { - if (field == null) { - return; - } - - optionalWrapperMarker.addFirst(field); - - buffer.beginTag(field.getName()); - } - - private void optionalWrapperEnd(FieldBase field) { - if (field == null) { - return; - } - - if (optionalWrapperMarker.removeFirst() != field) { - throw new IllegalStateException("Unbalanced optional wrapper tags."); - } - - buffer.endTag(); - } - - @Override - public void write(FieldBase field, Struct value) { - StructuredFieldValue asStructured = value; - write(field, asStructured); - } - - @Override - public void write(FieldBase field, StructuredFieldValue value) { - optionalWrapperStart(field); - Iterator> i = value.iterator(); - while (i.hasNext()) { - Map.Entry v = i.next(); - buffer.beginTag(v.getKey().getName()); - v.getValue().printXml(buffer); - buffer.endTag(); - } - optionalWrapperEnd(field); - } - - @Override - public void write(FieldBase field, - WeightedSet value) { - buffer.beginTag(field.getName()); - XmlSerializationHelper.printWeightedSetXml(value, buffer); - buffer.endTag(); - } - - @Override - public void write(FieldBase field, AnnotationReference value) { - // TODO Auto-generated method stub - - } - - @Override - public Serializer putByte(FieldBase field, byte value) { - singleValueTag(field, new ByteFieldValue(value)); - return this; - } - - @Override - public Serializer putShort(FieldBase field, short value) { - singleValueTag(field, new IntegerFieldValue(value)); - return this; - } - - @Override - public Serializer putInt(FieldBase field, int value) { - singleValueTag(field, new IntegerFieldValue(value)); - return this; - } - - @Override - public Serializer putLong(FieldBase field, long value) { - singleValueTag(field, new LongFieldValue(value)); - return this; - } - - @Override - public Serializer putFloat(FieldBase field, float value) { - singleValueTag(field, new FloatFieldValue(value)); - return this; - } - - @Override - public Serializer putDouble(FieldBase field, double value) { - singleValueTag(field, new DoubleFieldValue(value)); - return this; - } - - @Override - public Serializer put(FieldBase field, byte[] value) { - write(field, new Raw(value)); - return this; - } - - @Override - public Serializer put(FieldBase field, ByteBuffer value) { - write(field, new Raw(value)); - return this; - } - - @Override - public Serializer put(FieldBase field, String value) { - write(field, new StringFieldValue(value)); - return this; - } - - @Override - public void write(Document document) { - buffer = new XmlStream(); - buffer.setIndent(indent); - optionalWrapperMarker.clear(); - write(new Field(document.getDataType().getName(), 0, document.getDataType()), document); - } - - @Override - public void write(DocumentId id) { - throw new UnsupportedOperationException("Writing a DocumentId as XML is not implemented."); - } - - @Override - public void write(DocumentType type) { - throw new UnsupportedOperationException("Writing a DocumentId as XML is not implemented."); - - } - - public String lastRendered() { - return buffer.toString(); - } - -} 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 899ef1f9195..9c1df0cd6c7 100644 --- a/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java +++ b/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java @@ -30,6 +30,8 @@ import java.util.Map; * * @author Håkon Humberset */ +@Deprecated +@SuppressWarnings("removal") public class XmlSerializationHelper { public static void printArrayXml(Array array, XmlStream xml) { diff --git a/document/src/main/java/com/yahoo/document/serialization/XmlStream.java b/document/src/main/java/com/yahoo/document/serialization/XmlStream.java index 40ded73b5aa..b9e29d03f7f 100644 --- a/document/src/main/java/com/yahoo/document/serialization/XmlStream.java +++ b/document/src/main/java/com/yahoo/document/serialization/XmlStream.java @@ -27,6 +27,7 @@ import java.util.ListIterator; * * @author Haakon Humberset */ +@Deprecated public class XmlStream { // Utility class to hold attributes internally until it's time to write them diff --git a/document/src/test/java/com/yahoo/document/DocumentTestCase.java b/document/src/test/java/com/yahoo/document/DocumentTestCase.java index f1c74ad6efc..33b77cb1878 100644 --- a/document/src/test/java/com/yahoo/document/DocumentTestCase.java +++ b/document/src/test/java/com/yahoo/document/DocumentTestCase.java @@ -20,7 +20,6 @@ import com.yahoo.document.datatypes.WeightedSet; import com.yahoo.document.serialization.DocumentDeserializerFactory; import com.yahoo.document.serialization.DocumentReader; import com.yahoo.document.serialization.DocumentSerializerFactory; -import com.yahoo.document.serialization.XmlDocumentWriter; import com.yahoo.io.GrowableByteBuffer; import com.yahoo.vespa.objects.BufferSerializer; import org.junit.Test; @@ -920,6 +919,7 @@ public class DocumentTestCase extends DocumentTestCaseBase { } @Test + @SuppressWarnings("deprecation") public void testToXml() { setUpSertestDocType(); Document doc = getSertestDocument(); @@ -935,19 +935,7 @@ public class DocumentTestCase extends DocumentTestCaseBase { } @Test - public void testXmlSerializer() { - setUpSertestDocType(); - Document doc = getSertestDocument(); - doc.setFieldValue("mailid", "emailfromalicetobob&someone"); - doc.setFieldValue("myposfield", PositionDataType.valueOf(-122057174, 37374821)); - String xml = doc.toXML(" "); - XmlDocumentWriter w = XmlDocumentWriter.createWriter(" "); - w.write(doc); - String otherXml = doc.toXML(" "); - assertEquals(xml, otherXml); - } - - @Test + @SuppressWarnings("deprecation") public void testSingleFieldToXml() { Document doc = new Document(docMan.getDocumentType("testdoc"), new DocumentId("id:ns:testdoc::xmltest")); doc.setFieldValue("stringattr", new StringFieldValue("hello world")); @@ -955,6 +943,7 @@ public class DocumentTestCase extends DocumentTestCaseBase { } @Test + @SuppressWarnings("deprecation") public void testDelegatedDocumentToXml() { Document doc = new Document(docMan.getDocumentType("testdoc"), new DocumentId("id:ns:testdoc::xmltest")); doc.setFieldValue("stringattr", new StringFieldValue("hello universe")); @@ -1159,6 +1148,7 @@ public class DocumentTestCase extends DocumentTestCaseBase { } @Test + @SuppressWarnings("deprecation") public void testDocumentComparisonDoesNotCorruptStateBug6394548() { DocumentTypeManager docMan = new DocumentTypeManager(); DocumentType docType = new DocumentType("bug2354045"); diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug6394548TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug6394548TestCase.java index 3ec858062be..424fd0018c8 100644 --- a/document/src/test/java/com/yahoo/document/annotation/Bug6394548TestCase.java +++ b/document/src/test/java/com/yahoo/document/annotation/Bug6394548TestCase.java @@ -17,6 +17,7 @@ import static org.junit.Assert.*; public class Bug6394548TestCase { @Test + @SuppressWarnings("deprecation") public void testSerializeAndDeserializeMultipleAdjacentStructAnnotations() { DocumentTypeManager manager = new DocumentTypeManager(); var sub = DocumentTypeManagerConfigurer.configure @@ -65,6 +66,7 @@ public class Bug6394548TestCase { assertEquals(annotationsBefore, annotationsAfter); } + @SuppressWarnings("deprecation") private String dumpAllAnnotations(SpanTree tree) { ArrayList tmp = new ArrayList<>(); for (Annotation anno : tree) { diff --git a/document/src/test/java/com/yahoo/document/datatypes/PredicateFieldValueTest.java b/document/src/test/java/com/yahoo/document/datatypes/PredicateFieldValueTest.java index 95bdf8f4bc4..c77ad8493c9 100644 --- a/document/src/test/java/com/yahoo/document/datatypes/PredicateFieldValueTest.java +++ b/document/src/test/java/com/yahoo/document/datatypes/PredicateFieldValueTest.java @@ -53,6 +53,7 @@ public class PredicateFieldValueTest { } @Test + @SuppressWarnings("deprecation") public void requireThatXmlOutputIsEmptyForNullPredicate() { XmlStream expected = new XmlStream(); expected.beginTag("tag"); @@ -61,6 +62,7 @@ public class PredicateFieldValueTest { } @Test + @SuppressWarnings("deprecation") public void requireThatXmlOutputIsPredicateLanguage() { Predicate predicate = new FeatureSet("key", "valueA", "valueB"); XmlStream expected = new XmlStream(); @@ -181,6 +183,7 @@ public class PredicateFieldValueTest { assertTrue(lhs.equals(rhs)); } + @SuppressWarnings("deprecation") private static String printXml(String tag, FieldValue value) { XmlStream out = new XmlStream(); out.beginTag(tag); diff --git a/document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java b/document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java index ea066ff4ffd..06875b8ca3c 100644 --- a/document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java +++ b/document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java @@ -248,6 +248,7 @@ public class StructTestCase { } @Test + @SuppressWarnings("deprecation") public void testCompareToDoesNotMutateStateBug6394548() { StructDataType type = new StructDataType("test"); // NOTE: non-increasing ID order! diff --git a/document/src/test/java/com/yahoo/document/serialization/XmlDocumentWriterTestCase.java b/document/src/test/java/com/yahoo/document/serialization/XmlDocumentWriterTestCase.java deleted file mode 100644 index b291d3e784d..00000000000 --- a/document/src/test/java/com/yahoo/document/serialization/XmlDocumentWriterTestCase.java +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.document.serialization; - -import com.yahoo.document.DataType; -import com.yahoo.document.Document; -import com.yahoo.document.DocumentType; -import com.yahoo.document.Field; -import com.yahoo.document.datatypes.PredicateFieldValue; -import org.junit.Test; -import org.mockito.Mockito; - -/** - * @author Simon Thoresen Hult - */ -public class XmlDocumentWriterTestCase { - - @Test - public void requireThatPredicateFieldValuesAreSerializedAsString() { - DocumentType docType = new DocumentType("my_type"); - Field field = new Field("my_predicate", DataType.PREDICATE); - docType.addField(field); - Document doc = new Document(docType, "id:ns:my_type::"); - PredicateFieldValue predicate = Mockito.mock(PredicateFieldValue.class); - doc.setFieldValue("my_predicate", predicate); - - new XmlDocumentWriter().write(doc); - Mockito.verify(predicate, Mockito.times(1)).printXml(Mockito.any(XmlStream.class)); - } -} diff --git a/document/src/test/java/com/yahoo/document/serialization/XmlStreamTestCase.java b/document/src/test/java/com/yahoo/document/serialization/XmlStreamTestCase.java index afe08aeb2d6..4a66b562f35 100644 --- a/document/src/test/java/com/yahoo/document/serialization/XmlStreamTestCase.java +++ b/document/src/test/java/com/yahoo/document/serialization/XmlStreamTestCase.java @@ -1,11 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.document.serialization; -import com.yahoo.document.serialization.XmlStream; import org.junit.Test; -import java.io.IOException; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -14,6 +11,7 @@ import static org.junit.Assert.assertTrue; * * @author HÃ¥kon Humberset */ +@Deprecated public class XmlStreamTestCase { /** A catch all test checking that regular usage looks good. */ diff --git a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedFieldValue.java b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedFieldValue.java index a2c134ff71f..2fec321862e 100644 --- a/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedFieldValue.java +++ b/indexinglanguage/src/main/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedFieldValue.java @@ -27,6 +27,7 @@ public class UnresolvedFieldValue extends FieldValue { } @Override + @Deprecated public void printXml(XmlStream xml) { throw new UnsupportedOperationException(); } diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/FieldValueConverterTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/FieldValueConverterTestCase.java index 81b23bd98cf..1560e8bdf90 100644 --- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/FieldValueConverterTestCase.java +++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/FieldValueConverterTestCase.java @@ -397,6 +397,7 @@ public class FieldValueConverterTestCase { } @Override + @Deprecated public void printXml(XmlStream xml) { } diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/IfThenTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/IfThenTestCase.java index 7f07ad996e1..d429d340480 100644 --- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/IfThenTestCase.java +++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/IfThenTestCase.java @@ -283,6 +283,7 @@ public class IfThenTestCase { } @Override + @Deprecated public void printXml(XmlStream xml) { } diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedDataTypeTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedDataTypeTestCase.java index eaabafc501e..ad96ad86100 100644 --- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedDataTypeTestCase.java +++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedDataTypeTestCase.java @@ -35,6 +35,7 @@ public class UnresolvedDataTypeTestCase { } @Override + @Deprecated public void printXml(XmlStream xml) { } diff --git a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedFieldValueTestCase.java b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedFieldValueTestCase.java index a1c679e88f5..16195fa5052 100644 --- a/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedFieldValueTestCase.java +++ b/indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/expressions/UnresolvedFieldValueTestCase.java @@ -17,6 +17,7 @@ public class UnresolvedFieldValueTestCase { } @Test + @SuppressWarnings("deprecation") public void requireThatNoMethodsAreSupported() { UnresolvedFieldValue val = new UnresolvedFieldValue(); try { diff --git a/vespaclient-java/src/main/java/com/yahoo/dummyreceiver/DummyReceiver.java b/vespaclient-java/src/main/java/com/yahoo/dummyreceiver/DummyReceiver.java index 51668a2d7f7..c1459b2dfcf 100755 --- a/vespaclient-java/src/main/java/com/yahoo/dummyreceiver/DummyReceiver.java +++ b/vespaclient-java/src/main/java/com/yahoo/dummyreceiver/DummyReceiver.java @@ -78,6 +78,7 @@ public class DummyReceiver implements MessageHandler { System.out.println("Registered listener at " + name + "/default with 0 max pending and sleep time of " + sleepTime); } + @SuppressWarnings("deprecation") public void handleMessage(Message message) { long messageCount = this.messageCount.incrementAndGet(); if ( silentNum == 0 ) { diff --git a/vespaclient-java/src/main/java/com/yahoo/vespaget/DocumentRetriever.java b/vespaclient-java/src/main/java/com/yahoo/vespaget/DocumentRetriever.java index 0f17fa587e4..ff91b6e907b 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespaget/DocumentRetriever.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespaget/DocumentRetriever.java @@ -133,6 +133,7 @@ public class DocumentRetriever { return msg; } + @SuppressWarnings("deprecation") private void printReply(Reply reply) { Trace trace = reply.getTrace(); if (!trace.getRoot().isEmpty()) { diff --git a/vespaclient-java/src/main/java/com/yahoo/vespavisit/StdOutVisitorHandler.java b/vespaclient-java/src/main/java/com/yahoo/vespavisit/StdOutVisitorHandler.java index 0c7ad81f212..fc74cb6d899 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/StdOutVisitorHandler.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/StdOutVisitorHandler.java @@ -32,6 +32,7 @@ import java.util.logging.Logger; * * @author Thomas Gundersen */ +@SuppressWarnings("deprecation") public class StdOutVisitorHandler extends VdsVisitHandler { private static final Logger log = Logger.getLogger( diff --git a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java index 340d4a7eb81..a6e34055fbd 100644 --- a/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java +++ b/vespaclient-java/src/main/java/com/yahoo/vespavisit/VdsVisit.java @@ -369,7 +369,7 @@ public class VdsVisit { private boolean abortOnClusterDown = false; private int processTime = 0; private int fullTimeout = 7 * 24 * 60 * 60 * 1000; - private boolean jsonOutput = false; + private boolean jsonOutput = true; private boolean tensorShortForm = false; // TODO Vespa 9: change default to true private boolean tensorDirectValues = false; // TODO Vespa 9: change default to true -- cgit v1.2.3