Package com.yahoo.processing.rendering
Class ProcessingRenderer
java.lang.Object
com.yahoo.component.AbstractComponent
com.yahoo.processing.rendering.Renderer<RESPONSE>
com.yahoo.processing.rendering.AsynchronousRenderer<RESPONSE>
com.yahoo.processing.rendering.AsynchronousSectionedRenderer<Response>
com.yahoo.processing.rendering.ProcessingRenderer
- All Implemented Interfaces:
com.yahoo.component.Component
,com.yahoo.component.Deconstructable
,Cloneable
,Comparable<com.yahoo.component.Component>
The default renderer for processing responses. Renders a response in JSON.
This can be overridden to specify particular rendering of leaf Data elements.
This default implementation renders the toString of each element.
- Author:
- bratseth
-
Field Summary
Fields inherited from class com.yahoo.component.AbstractComponent
isDeconstructable
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Invoked at the beginning of each data list, including the implicit, outermost one in the response.final void
beginResponse
(OutputStream stream) Invoked once at the beginning of rendering a response.final void
Invoked for each leaf node in the data treefinal void
Invoked at the end of each data list, including the implicit, outermost one in the response.final void
Invoked once at the end of rendering a response.final String
Name of the output encoding, if applicable.final String
The MIME type of the rendered content sent to the client.void
init()
Do per instance initialization.protected void
renderValue
(Data data, com.yahoo.text.JSONWriter writer) Renders the value of a data element.protected boolean
shouldRender
(Data data) Returns whether this data element should be rendered.Methods inherited from class com.yahoo.processing.rendering.AsynchronousSectionedRenderer
clientClosed, deconstruct, getExecution, getRecursionLevel, getResponse, onClientClosed, renderResponse, renderResponseBeforeHandover, setNetworkWiring
Methods inherited from class com.yahoo.component.AbstractComponent
compareTo, getClassName, getId, getIdString, hasInitializedId, initId, isDeconstructable, setIsDeconstructable, toString
-
Constructor Details
-
ProcessingRenderer
public ProcessingRenderer()
-
-
Method Details
-
init
public void init()Description copied from class:AsynchronousSectionedRenderer
Do per instance initialization. If overriding this in a subclass, not invoking it in the subclass' implementation will most likely cause the rendering to fail with an exception.- Overrides:
init
in classAsynchronousSectionedRenderer<Response>
-
beginResponse
Description copied from class:AsynchronousSectionedRenderer
Invoked once at the beginning of rendering a response. This assigns the stream to be used throughput the rendering. Subsequent calls must use the same stream.- Specified by:
beginResponse
in classAsynchronousSectionedRenderer<Response>
- Parameters:
stream
- the stream to render to in this and all subsequent calls.- Throws:
IOException
- passed on from the stream
-
endResponse
Description copied from class:AsynchronousSectionedRenderer
Invoked once at the end of rendering a response.- Specified by:
endResponse
in classAsynchronousSectionedRenderer<Response>
- Throws:
IOException
- passed on from the stream
-
beginList
Description copied from class:AsynchronousSectionedRenderer
Invoked at the beginning of each data list, including the implicit, outermost one in the response.- Specified by:
beginList
in classAsynchronousSectionedRenderer<Response>
- Parameters:
list
- the data list which now will be rendered- Throws:
IOException
- passed on from the stream
-
endList
Description copied from class:AsynchronousSectionedRenderer
Invoked at the end of each data list, including the implicit, outermost one in the response.- Specified by:
endList
in classAsynchronousSectionedRenderer<Response>
- Parameters:
list
- the data list which now has no more data items to render- Throws:
IOException
- passed on from the stream
-
data
Description copied from class:AsynchronousSectionedRenderer
Invoked for each leaf node in the data tree- Specified by:
data
in classAsynchronousSectionedRenderer<Response>
- Parameters:
data
- the leaf node to render- Throws:
IOException
- passed on from the stream
-
renderValue
Renders the value of a data element. This default implementation does writer.fieldValue(data.toString()) Override this to render data in application specific ways.- Throws:
IOException
-
shouldRender
Returns whether this data element should be rendered. This can be overridden to add new kinds of data which should not be rendered. This default implementation returns true unless the data is instanceof ResponseHeaders.- Returns:
- true to render it, false to skip completely
-
getEncoding
Description copied from class:Renderer
Name of the output encoding, if applicable.- Specified by:
getEncoding
in classRenderer<Response>
- Returns:
- the encoding of the output if applicable, e.g. "utf-8"
-
getMimeType
Description copied from class:Renderer
The MIME type of the rendered content sent to the client.- Specified by:
getMimeType
in classRenderer<Response>
- Returns:
- The mime type of the data written to the writer, e.g. "text/plain"
-