- Type Parameters:
T
- the model type
- All Superinterfaces:
Renderer<T>
,Template<T>
,TemplateInfo
- All Known Implementing Classes:
ExampleModelRenderer
,HelloModelAndViewView
,HelloModelView
,HelloModelView
,MessagePageRenderer
,MessagePageRenderer
JStacheType.JSTACHIO
templates that are generated are of this type. To
disable see JStacheFlags.Flag.PRE_ENCODE_DISABLE
.
This interface is to support Rocker style near zero-copy rendering where the static template parts are stored as byte arrays.
The passed in OutputStream
will only have
OutputStream.write(byte[])
called thus an array or list of byte arrays
can be accumulated to support almost zero-copy. Consequently absolutely no
mutation of the byte arrays should happen as they could be reusable static parts of
the template!
Overall it is recommended that you do not use this interface unless you have an
intimate knowledge of how your platform buffers data and have byte like access as
current JMH benchmarking indicates that
String.getBytes(java.nio.charset.Charset)
is generally much faster for raw
byte conversion albeit at the possible cost of increased memory. One should peform
their own benchmarking to confirm using this interface is worth it.
- Author:
- agentgt
- See Also:
- API Note
- The passed in
OutputStream
will only haveOutputStream.write(byte[])
called and no mutation of the passed in byte array should happen downstream.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jstach.jstachio.Template
Template.EncodedTemplate<T>
Nested classes/interfaces inherited from interface io.jstach.jstachio.TemplateInfo
TemplateInfo.TemplateSource
-
Field Summary
Fields inherited from interface io.jstach.jstachio.TemplateInfo
TEMPLATE_BINDING_NAME
-
Method Summary
Modifier and TypeMethodDescriptiondefault TemplateModel
Creates a template model pair.<A extends Output.EncodedOutput<E>,
E extends Exception>
ARenders the passed in model directly to a binary stream leveraging pre-encoded parts of the template.default void
write
(T model, OutputStream outputStream) Renders the passed in model directly to a binary stream leveraging pre-encoded parts of the template.Methods inherited from interface io.jstach.jstachio.TemplateInfo
description, lastLoaded, modelClass, normalizePath, supportsType, templateCharset, templateContentType, templateEscaper, templateFormatter, templateMediaType, templateName, templatePath, templateSource, templateString
-
Method Details
-
write
Renders the passed in model directly to a binary stream 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()
.- Specified by:
write
in interfaceTemplate<T>
- Parameters:
model
- a model assumed never to benull
.outputStream
- to write to.- Throws:
IOException
- if an error occurs while writing to the outputStream- See Also:
- API Note
- The stream will not be closed or flushed by this call.
-
write
Renders the passed in model directly to a binary stream 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()
. -
model
Description copied from interface:Template
Creates a template model pair.
-