java.lang.Object
io.jstach.jstachio.spi.AbstractJStachio
- All Implemented Interfaces:
JStachio
,Renderer<Object>
,JStachioExtensions.Provider
- Direct Known Subclasses:
SpringJStachio
public abstract class AbstractJStachio
extends Object
implements JStachio, JStachioExtensions.Provider
An abstract jstachio that just needs a
JStachioExtensions
container.
To extend just override JStachioExtensions.Provider.extensions()
.
- Author:
- agentgt
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRenders the passed in model.findTemplate
(Object model) Finds a template by model.protected final JStachioFilter.FilterChain
loadFilter
(Object model, TemplateInfo template) Loads the filter and checks if it can process the model and template.final boolean
supportsType
(Class<?> modelType) Determines if this jstachio can render the model type (the class annotated by JStache).protected TemplateInfo
Finds the template by model class wrapping any exceptions.<A extends Output.EncodedOutput<E>,
E extends Exception>
ARenders the passed in model directly to a binary stream possibly leveraging pre-encoded parts of the template.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jstach.jstachio.spi.JStachioExtensions.Provider
extensions
-
Constructor Details
-
AbstractJStachio
public AbstractJStachio()Do nothing constructor
-
-
Method Details
-
execute
Description copied from interface:Renderer
Renders the passed in model.- Specified by:
execute
in interfaceRenderer<Object>
- Type Parameters:
A
- output typeE
- error type- Parameters:
model
- a model assumed never to benull
.appendable
- the output to write to.- Returns:
- the output passed in returned for convenience.
- Throws:
E
- if there is an error writing to the output
-
write
public <A extends Output.EncodedOutput<E>,E extends Exception> A write(Object model, A appendable) throws E Description copied from interface:JStachio
Renders the passed in model directly to a binary stream possibly leveraging pre-encoded parts of the template. This may improve performance when rendering UTF-8 to an OutputStream as some of the encoding is done in advance. Because the encoding is done statically you cannot pass the charset in. The chosen charset comes fromJStacheConfig.charset()
. -
findTemplate
Description copied from interface:JStachio
Finds a template by model. This is useful if you need metadata before writing such as charset and media type for HTTP output which the template has.The returned template is decorated if filtering is on and a filter that is not the template is applied.
Passing in a
TemplateModel
should work as well and the returned template will be able to execute the TemplateModel as though it were a regular model.- Specified by:
findTemplate
in interfaceJStachio
- Parameters:
model
- the actual model or aTemplateModel
containing the model- Returns:
- a filtered template
-
loadFilter
Loads the filter and checks if it can process the model and template.- Parameters:
model
- to rendertemplate
- loaded bytemplate(Class)
- Returns:
- filter chain that can process model
-
supportsType
Description copied from interface:JStachio
Determines if this jstachio can render the model type (the class annotated by JStache).- Specified by:
supportsType
in interfaceJStachio
- Parameters:
modelType
- the models class (the one annotated withJStache
and not the Templates class)- Returns:
- true if this jstachio can render instances of modelType
-
template
Finds the template by model class wrapping any exceptions.- Parameters:
modelType
- the class of the model.- Returns:
- found template never
null
.
-