public class ConstantEmitter extends Emitter
| Modifier and Type | Field and Description |
|---|---|
static ConstantEmitter |
EMPTY
Represents an empty emitter which does not contribute the the output.
|
startOfBlock| Constructor and Description |
|---|
ConstantEmitter(parsii.tokenizer.Position startOfBlock)
Creates a new constant emitter at the given position.
|
| Modifier and Type | Method and Description |
|---|---|
ConstantEmitter |
append(String stringToAppend)
Appends the given string to the output.
|
Emitter |
copy()
Creates a copy of the emitter.
|
protected void |
emitToContext(LocalRenderContext context)
Actually produces the output while relying on the caller to properly handle any exception.
|
String |
getValue()
Returns the underlying text block which will be emitted.
|
Emitter |
propagateVisitor(EmitterVisitor visitor)
Invokes the visitor on all sub emitters and on this emitter itself.
|
Emitter |
reduce()
Performs static optimizations at compile time.
|
String |
toString() |
void |
visitExpressions(Function<parsii.tokenizer.Position,ExpressionVisitor> visitorSupplier)
Visits all expressions contained in this emitter or its children.
|
emit, getStartOfBlockpublic static final ConstantEmitter EMPTY
public ConstantEmitter(parsii.tokenizer.Position startOfBlock)
startOfBlock - the position where the emitter was created.public Emitter copy()
Although the emitter is constant, we still need to create a copy, as the CompositeEmitter folds adjacent
constant blocks into one.
public Emitter reduce()
EmitterCertain emitters can perform optimizations (evaluate constant expressions, combine constant outputs etc.) to create more efficient templates. This is especially important when a template is inlined, as this most probably provides a higher level of optimizations.
public Emitter propagateVisitor(EmitterVisitor visitor)
EmitterpropagateVisitor in class Emittervisitor - the visitor to invokepublic void visitExpressions(Function<parsii.tokenizer.Position,ExpressionVisitor> visitorSupplier)
EmittervisitExpressions in class EmittervisitorSupplier - a function which generates an ExpressionVisitor while supplying the current position (for
improved error messages).public ConstantEmitter append(String stringToAppend)
stringToAppend - the text to appendprotected void emitToContext(LocalRenderContext context) throws Exception
EmitteremitToContext in class Emittercontext - the render context which provides access to the local and global environment and also the target
for the generated textException - all thrown exceptions are caught and converted into a RenderExceptionpublic String getValue()
Copyright © 2018. All rights reserved.