aboutsummaryrefslogtreecommitdiffstats
path: root/sample-apps/http-api-using-searcher/src/main/java/com/yahoo/demo/DemoRenderer.java
diff options
context:
space:
mode:
Diffstat (limited to 'sample-apps/http-api-using-searcher/src/main/java/com/yahoo/demo/DemoRenderer.java')
-rw-r--r--sample-apps/http-api-using-searcher/src/main/java/com/yahoo/demo/DemoRenderer.java74
1 files changed, 0 insertions, 74 deletions
diff --git a/sample-apps/http-api-using-searcher/src/main/java/com/yahoo/demo/DemoRenderer.java b/sample-apps/http-api-using-searcher/src/main/java/com/yahoo/demo/DemoRenderer.java
deleted file mode 100644
index dd5ea469620..00000000000
--- a/sample-apps/http-api-using-searcher/src/main/java/com/yahoo/demo/DemoRenderer.java
+++ /dev/null
@@ -1,74 +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.demo;
-
-import com.yahoo.search.Result;
-import com.yahoo.search.rendering.Renderer;
-import com.yahoo.search.result.Hit;
-import com.yahoo.search.result.HitGroup;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Iterator;
-
-/**
- * Render result sets as plain text. First line is whether an error occurred,
- * second rendering initialization time stamp, then each line is the ID of each
- * document returned, and the last line is time stamp for when the renderer was
- * finished.
- */
-public class DemoRenderer extends Renderer {
- private String heading;
-
- /**
- * No global, shared state to set.
- */
- public DemoRenderer() {
- }
-
- @Override
- protected void render(Writer writer, Result result) throws IOException {
- if (result.hits().getErrorHit() == null) {
- writer.write("OK\n");
- } else {
- writer.write("Oops!\n");
- }
- writer.write(heading);
- writer.write("\n");
- renderHits(writer, result.hits());
- writer.write("Rendering finished work: " + System.currentTimeMillis());
- writer.write("\n");
- }
-
- private void renderHits(Writer writer, HitGroup hits) throws IOException {
- for (Iterator<Hit> i = hits.deepIterator(); i.hasNext();) {
- Hit h = i.next();
- if (h.types().contains("summary")) {
- String id = h.getDisplayId();
- if (id != null) {
- writer.write(id);
- writer.write("\n");
- }
- }
- }
- }
-
- @Override
- public String getEncoding() {
- return "utf-8";
- }
-
- @Override
- public String getMimeType() {
- return "text/plain";
- }
-
- /**
- * Initialize mutable, per-result set state here.
- */
- @Override
- public void init() {
- long time = System.currentTimeMillis();
- heading = "Renderer initialized: " + time;
- }
-
-}