From bb26b9f9a5ba9175b6b81a0c8c2f54de19002cc8 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Thu, 8 Nov 2018 16:42:45 +0100 Subject: Remove old feedapi --- .../storage/searcher/DocumentFieldTemplate.java | 98 ---------------------- 1 file changed, 98 deletions(-) delete mode 100755 vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java (limited to 'vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java') diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java b/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java deleted file mode 100755 index cf35c789f65..00000000000 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/storage/searcher/DocumentFieldTemplate.java +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.storage.searcher; - -import com.yahoo.document.DataType; -import com.yahoo.document.Document; -import com.yahoo.document.Field; -import com.yahoo.document.datatypes.FieldValue; -import com.yahoo.document.datatypes.Raw; -import com.yahoo.io.ByteWriter; -import com.yahoo.text.XML; - -import java.io.IOException; -import java.io.Writer; - -/** - * Template used to render a single field for a single Document. Fields - * that are either of type CONTENT or RAW are written directly, while - * all other fields are wrapped in Vespa XML and escaped. - * - * @deprecated use a renderer instead - */ -@Deprecated // OK -// TODO: Remove on Vespa 7 -@SuppressWarnings("deprecation") -public class DocumentFieldTemplate extends com.yahoo.prelude.templates.UserTemplate { - - Field field; - String contentType; - String encoding; - boolean wrapXml; - - public DocumentFieldTemplate(Field field, String contentType, String encoding, boolean wrapXml) { - super("documentfield", contentType, encoding); - this.field = field; - this.contentType = contentType; - this.encoding = encoding; - this.wrapXml = wrapXml; - } - - @Override - public void error(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException { - // Error shouldn't be handled by this template, but rather - // delegated to the searcher - } - - @Override - public Writer wrapWriter(Writer writer) { - /* TODO: uncomment - if (!(writer instanceof ByteWriter)) { - throw new IllegalArgumentException("ByteWriter required, but got " + writer.getClass().getName()); - } - */ - - return writer; - } - - @Override - public void header(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException { - if (wrapXml) { - // XML wrapping should only be used for default field rendering - writer.write("\n"); - writer.write(""); - } - } - - @Override - public void footer(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException { - if (wrapXml) { - writer.write("\n"); - } - } - - @Override - public void hit(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException { - DocumentHit hit = (DocumentHit)context.get("hit"); - Document doc = hit.getDocument(); - // Assume field existence has been checked before we ever get here. - // Also assume that relevant encoding/content type is set - // appropriately according to the request and the field's content - // type, as this is immutable in the template set. - FieldValue value = doc.getFieldValue(field); - if (field.getDataType() == DataType.RAW) { - ByteWriter bw = (ByteWriter)writer; - bw.append(((Raw) value).getByteBuffer().array()); - } else { - writer.write(XML.xmlEscape(value.toString(), false)); - } - } - - @Override - public void hitFooter(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException { - } - - @Override - public void noHits(com.yahoo.prelude.templates.Context context, Writer writer) throws IOException { - } - -} -- cgit v1.2.3