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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidInvoked at the beginning of each data list, including the implicit, outermost one in the response.final voidbeginResponse(OutputStream stream) Invoked once at the beginning of rendering a response.final voidInvoked for each leaf node in the data treefinal voidInvoked at the end of each data list, including the implicit, outermost one in the response.final voidInvoked once at the end of rendering a response.final StringName of the output encoding, if applicable.final StringThe MIME type of the rendered content sent to the client.voidinit()Do per instance initialization.protected voidrenderValue(Data data, com.yahoo.text.JSONWriter writer) Renders the value of a data element.protected booleanshouldRender(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, setNetworkWiringMethods 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:AsynchronousSectionedRendererDo 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:
initin classAsynchronousSectionedRenderer<Response>
-
beginResponse
Description copied from class:AsynchronousSectionedRendererInvoked 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:
beginResponsein 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:AsynchronousSectionedRendererInvoked once at the end of rendering a response.- Specified by:
endResponsein classAsynchronousSectionedRenderer<Response>- Throws:
IOException- passed on from the stream
-
beginList
Description copied from class:AsynchronousSectionedRendererInvoked at the beginning of each data list, including the implicit, outermost one in the response.- Specified by:
beginListin classAsynchronousSectionedRenderer<Response>- Parameters:
list- the data list which now will be rendered- Throws:
IOException- passed on from the stream
-
endList
Description copied from class:AsynchronousSectionedRendererInvoked at the end of each data list, including the implicit, outermost one in the response.- Specified by:
endListin 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:AsynchronousSectionedRendererInvoked for each leaf node in the data tree- Specified by:
datain 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:RendererName of the output encoding, if applicable.- Specified by:
getEncodingin classRenderer<Response>- Returns:
- the encoding of the output if applicable, e.g. "utf-8"
-
getMimeType
Description copied from class:RendererThe MIME type of the rendered content sent to the client.- Specified by:
getMimeTypein classRenderer<Response>- Returns:
- The mime type of the data written to the writer, e.g. "text/plain"
-