Class Renderer

java.lang.Object
com.yahoo.component.AbstractComponent
com.yahoo.processing.rendering.Renderer<Result>
com.yahoo.search.rendering.Renderer
All Implemented Interfaces:
com.yahoo.component.Component, com.yahoo.component.Deconstructable, Cloneable, Comparable<com.yahoo.component.Component>
Direct Known Subclasses:
SectionedRenderer, SyncDefaultRenderer

public abstract class Renderer extends com.yahoo.processing.rendering.Renderer<Result>
Renders a search result to a writer synchronously - the result is completely rendered when the render method returns. The renderers are cloned just before rendering, and must therefore obey the following contract:
  1. At construction time, only final members shall be initialized, and these must refer to immutable data only.
  2. State mutated during rendering shall be initialized in the init method.
Author:
Tony Vaagenes
  • Field Summary

    Fields inherited from class com.yahoo.component.AbstractComponent

    isDeconstructable
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Used to create a separate instance for each result to render.
     
     
    final String
    Returns the encoding of the query, or the encoding given by the template if none is set
    protected abstract void
    render(Writer writer, Result result)
    Renders the result to the writer.
    renderResponse(OutputStream stream, Result response, com.yahoo.processing.execution.Execution execution, com.yahoo.processing.Request request)
    Renders synchronously and returns when rendering is complete.

    Methods inherited from class com.yahoo.processing.rendering.Renderer

    getEncoding, getMimeType, init

    Methods inherited from class com.yahoo.component.AbstractComponent

    compareTo, deconstruct, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable, toString

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Renderer

      public Renderer()
  • Method Details

    • renderResponse

      public final CompletableFuture<Boolean> renderResponse(OutputStream stream, Result response, com.yahoo.processing.execution.Execution execution, com.yahoo.processing.Request request)
      Renders synchronously and returns when rendering is complete.
      Specified by:
      renderResponse in class com.yahoo.processing.rendering.Renderer<Result>
      Returns:
      a future which is always completed to true
    • render

      protected abstract void render(Writer writer, Result result) throws IOException
      Renders the result to the writer.
      Throws:
      IOException
    • getCharacterEncoding

      public String getCharacterEncoding(Result result)
    • getDefaultSummaryClass

      public String getDefaultSummaryClass()
      Returns:
      The summary class to fill the hits with if no summary class was specified in the query presentation.
    • getRequestedEncoding

      public final String getRequestedEncoding(Query query)
      Returns the encoding of the query, or the encoding given by the template if none is set
    • clone

      public Renderer clone()
      Used to create a separate instance for each result to render.
      Overrides:
      clone in class com.yahoo.processing.rendering.Renderer<Result>