Package com.yahoo.search.rendering
Class JsonRenderer
- java.lang.Object
-
- com.yahoo.component.AbstractComponent
-
- com.yahoo.processing.rendering.Renderer<RESPONSE>
-
- com.yahoo.processing.rendering.AsynchronousRenderer<RESPONSE>
-
- com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
-
- com.yahoo.search.rendering.JsonRenderer
-
- All Implemented Interfaces:
com.yahoo.component.Component
,java.lang.Cloneable
,java.lang.Comparable<com.yahoo.component.Component>
public class JsonRenderer extends com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
JSON renderer for search results.- Author:
- Steinar Knutsen, bratseth
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JsonRenderer.FieldConsumer
Received callbacks when fields of hits are encountered.
-
Constructor Summary
Constructors Constructor Description JsonRenderer()
JsonRenderer(java.util.concurrent.Executor executor)
Creates a json renderer using a custom executor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginList(com.yahoo.processing.response.DataList<?> list)
void
beginResponse(java.io.OutputStream stream)
protected JsonRenderer.FieldConsumer
createFieldConsumer(com.fasterxml.jackson.core.JsonGenerator generator, boolean debugRendering)
protected static com.fasterxml.jackson.databind.ObjectMapper
createJsonCodec()
Create the codec used for rendering instances ofTreeNode
.void
data(com.yahoo.processing.response.Data data)
void
endList(com.yahoo.processing.response.DataList<?> list)
void
endResponse()
java.lang.String
getEncoding()
java.lang.String
getMimeType()
void
init()
protected void
moreChildren()
protected void
renderAllFields(Hit hit)
protected void
renderContinuations(java.util.Map<java.lang.String,Continuation> continuations)
protected void
renderCoverage()
protected void
renderErrors(java.util.Set<ErrorMessage> errors)
protected void
renderGroupMetadata(GroupId id)
protected void
renderHit(Hit hit)
protected void
renderHitContents(Hit hit)
protected void
renderHitGroupHead(HitGroup hitGroup)
protected void
renderTotalHitCount(Hit hit)
protected void
renderTrace(com.yahoo.processing.execution.Execution.Trace trace)
protected boolean
shouldRender(Hit hit)
-
Methods inherited from class com.yahoo.processing.rendering.AsynchronousSectionedRenderer
clientClosed, deconstruct, getExecution, getRecursionLevel, getResponse, onClientClosed, render, renderBeforeHandover, setNetworkWiring
-
-
-
-
Method Detail
-
createJsonCodec
protected static com.fasterxml.jackson.databind.ObjectMapper createJsonCodec()
Create the codec used for rendering instances ofTreeNode
. 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 classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
-
beginResponse
public void beginResponse(java.io.OutputStream stream) throws java.io.IOException
- Specified by:
beginResponse
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
java.io.IOException
-
renderTrace
protected void renderTrace(com.yahoo.processing.execution.Execution.Trace trace) throws java.io.IOException
- Throws:
java.io.IOException
-
beginList
public void beginList(com.yahoo.processing.response.DataList<?> list) throws java.io.IOException
- Specified by:
beginList
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
java.io.IOException
-
moreChildren
protected void moreChildren() throws java.io.IOException
- Throws:
java.io.IOException
-
renderHitGroupHead
protected void renderHitGroupHead(HitGroup hitGroup) throws java.io.IOException
- Throws:
java.io.IOException
-
renderErrors
protected void renderErrors(java.util.Set<ErrorMessage> errors) throws java.io.IOException
- Throws:
java.io.IOException
-
renderCoverage
protected void renderCoverage() throws java.io.IOException
- Throws:
java.io.IOException
-
renderHit
protected void renderHit(Hit hit) throws java.io.IOException
- Throws:
java.io.IOException
-
shouldRender
protected boolean shouldRender(Hit hit)
-
renderHitContents
protected void renderHitContents(Hit hit) throws java.io.IOException
- Throws:
java.io.IOException
-
renderAllFields
protected void renderAllFields(Hit hit) throws java.io.IOException
- Throws:
java.io.IOException
-
renderContinuations
protected void renderContinuations(java.util.Map<java.lang.String,Continuation> continuations) throws java.io.IOException
- Throws:
java.io.IOException
-
renderGroupMetadata
protected void renderGroupMetadata(GroupId id) throws java.io.IOException
- Throws:
java.io.IOException
-
renderTotalHitCount
protected void renderTotalHitCount(Hit hit) throws java.io.IOException
- Throws:
java.io.IOException
-
data
public void data(com.yahoo.processing.response.Data data) throws java.io.IOException
- Specified by:
data
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
java.io.IOException
-
endList
public void endList(com.yahoo.processing.response.DataList<?> list) throws java.io.IOException
- Specified by:
endList
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
java.io.IOException
-
endResponse
public void endResponse() throws java.io.IOException
- Specified by:
endResponse
in classcom.yahoo.processing.rendering.AsynchronousSectionedRenderer<Result>
- Throws:
java.io.IOException
-
getEncoding
public java.lang.String getEncoding()
- Specified by:
getEncoding
in classcom.yahoo.processing.rendering.Renderer<Result>
-
getMimeType
public java.lang.String getMimeType()
- Specified by:
getMimeType
in classcom.yahoo.processing.rendering.Renderer<Result>
-
createFieldConsumer
protected JsonRenderer.FieldConsumer createFieldConsumer(com.fasterxml.jackson.core.JsonGenerator generator, boolean debugRendering)
-
-