Class JsonRenderer

  • All Implemented Interfaces:
    com.yahoo.component.Component, com.yahoo.component.Deconstructable, Cloneable, Comparable<com.yahoo.component.Component>

    public class JsonRenderer
    extends com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
    JSON renderer for search results.
    Author:
    Steinar Knutsen, bratseth
    • Constructor Detail

      • JsonRenderer

        public JsonRenderer()
      • JsonRenderer

        public JsonRenderer​(Executor executor)
        Creates a json renderer using a custom executor. Using a custom executor is useful for tests to avoid creating new threads for each renderer registry.
    • Method Detail

      • createJsonCodec

        @Deprecated(forRemoval=true,
                    since="7")
        protected static com.fasterxml.jackson.databind.ObjectMapper createJsonCodec()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Will be removed in Vespa 8. Override the individual render methods of JsonRenderer to alter rendering behaviour. Override createFieldConsumer(boolean) and sub-class JsonRenderer.FieldConsumer to alter rendering of hit fields.
        Create the codec used for rendering instances of TreeNode. This method will be invoked when creating the first renderer instance, but not for each fresh clone used by individual results.
        Returns:
        an object mapper for the internal JsonFactory
      • init

        public void init()
        Overrides:
        init in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
      • beginResponse

        public void beginResponse​(OutputStream stream)
                           throws IOException
        Specified by:
        beginResponse in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
        Throws:
        IOException
      • renderTrace

        protected void renderTrace​(com.yahoo.processing.execution.Execution.Trace trace)
                            throws IOException
        Throws:
        IOException
      • beginList

        public void beginList​(com.yahoo.processing.response.DataList<?> list)
                       throws IOException
        Specified by:
        beginList in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
        Throws:
        IOException
      • shouldRender

        protected boolean shouldRender​(Hit hit)
      • data

        public void data​(com.yahoo.processing.response.Data data)
                  throws IOException
        Specified by:
        data in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
        Throws:
        IOException
      • endList

        public void endList​(com.yahoo.processing.response.DataList<?> list)
                     throws IOException
        Specified by:
        endList in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
        Throws:
        IOException
      • endResponse

        public void endResponse()
                         throws IOException
        Specified by:
        endResponse in class com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
        Throws:
        IOException
      • getEncoding

        public String getEncoding()
        Specified by:
        getEncoding in class com.yahoo.processing.rendering.Renderer<Result>
      • getMimeType

        public String getMimeType()
        Specified by:
        getMimeType in class com.yahoo.processing.rendering.Renderer<Result>