public interface IEngineContext extends ITemplateContext
Mostly-internal interface implemented by all classes containing the context required for template processing inside the engine itself.
This interface extends ITemplateContext
by adding a series of methods required internally
by the template engine for processing, which should not be used from users' code.
Calling these methods directly from custom processors or other extensions could have undesirable
effects on template processing.
Contexts used during template processing by the engine are always implementations of this interface.
If the Template Engine is called with an implementation of this IEngineContext
as
context, the same object will be used (so that users can actually provide their own implementations).
On the other side, if the context specified to the Template Engine is not an implementation of this
interface, an implementation of IEngineContext
will be internally created by the engine, the original
context's variables and other info will be cloned, and used instead.
Again note that, besides providing custom-made implementations of this interface (which is a very complex operation, not recommended in most scenarios) there should be no reason why this interface should ever be used in users' code.
Modifier and Type | Method and Description |
---|---|
void |
decreaseLevel()
Decrease the context level.
|
List<IProcessableElementTag> |
getElementStackAbove(int contextLevel)
Retrieves the element stack just like
ITemplateContext.getElementStack() , but only for those elements added
to the hierarchy above a specific context level. |
void |
increaseLevel()
Increase the context level.
|
boolean |
isVariableLocal(String name)
Checks whether a specific variable is local or not.
|
int |
level()
Return the current context level.
|
void |
removeVariable(String name)
Removes a variable from the context.
|
void |
setElementTag(IProcessableElementTag elementTag)
Sets a new element tag (
IProcessableElementTag ) into the hierarchy (stack) of element tags. |
void |
setInliner(IInliner inliner)
Set an inliner.
|
void |
setSelectionTarget(Object selectionTarget)
Set a selection target.
|
void |
setTemplateData(TemplateData template)
Sets a new template metadata object (
TemplateData ) for the current execution point, specifying
that the elements and nodes that are to be processed from now on (until the context level is
decreased below the current level) originally belonged to a different template. |
void |
setVariable(String name,
Object value)
Sets a new variable into the context.
|
void |
setVariables(Map<String,Object> variables)
Sets several variables at a time into the context.
|
buildLink, getElementStack, getIdentifierSequences, getInliner, getMessage, getModelFactory, getSelectionTarget, getTemplateData, getTemplateMode, getTemplateResolutionAttributes, getTemplateStack, hasSelectionTarget
getConfiguration, getExpressionObjects
containsVariable, getLocale, getVariable, getVariableNames
void setVariable(String name, Object value)
Sets a new variable into the context.
Depending on the context level, determined by increaseLevel()
and
decreaseLevel()
, the variable being set might be considered a local variable
and thus disappear from context once the context level is decreased below the
level the variable was created at.
name
- the name of the variable.value
- the value of the variable.void setVariables(Map<String,Object> variables)
Sets several variables at a time into the context.
Depending on the context level, determined by increaseLevel()
and
decreaseLevel()
, the variables being set might be considered a local variables
and thus disappear from context once the context level is decreased below the
level the variable was created at.
variables
- the variables to be set.void removeVariable(String name)
Removes a variable from the context.
Depending on the context level, determined by increaseLevel()
and
decreaseLevel()
, this removal might be considered local variable-related
and thus cease to happen (i.e. the variable would be recovered) once the context level
is decreased below the level the variable was created at.
name
- the name of the variable to be removed.void setSelectionTarget(Object selectionTarget)
Set a selection target. Usually the consequence of executing a th:object processor.
Once set, all selection expressions (*{...}) will be executed on this target.
This selection target will have the consideration of a local variable and thus depend on
the context level (see setVariable(String, Object)
).
selectionTarget
- the selection target to be set.void setInliner(IInliner inliner)
Set an inliner. Usually the consequence of executing a th:inline processor.
This inliner will have the consideration of a local variable and thus depend on
the context level (see setVariable(String, Object)
).
inliner
- the inliner to be set.void setTemplateData(TemplateData template)
Sets a new template metadata object (TemplateData
) for the current execution point, specifying
that the elements and nodes that are to be processed from now on (until the context level is
decreased below the current level) originally belonged to a different template.
A call on this method is usually the consequence of th:insert or th:replace.
template
- the template data.void setElementTag(IProcessableElementTag elementTag)
Sets a new element tag (IProcessableElementTag
) into the hierarchy (stack) of element tags.
This hierarchy of element tags (added this way) can be obtained with ITemplateContext.getElementStack()
.
elementTag
- the element tag.List<IProcessableElementTag> getElementStackAbove(int contextLevel)
Retrieves the element stack just like ITemplateContext.getElementStack()
, but only for those elements added
to the hierarchy above a specific context level.
contextLevel
- the level above which we want to obtain the element stack.boolean isVariableLocal(String name)
Checks whether a specific variable is local or not.
This means checking if the context level at which the variable was defined was 0 or not.
name
- the name of the variable to be checked.void increaseLevel()
Increase the context level. This is usually a consequence of the
ProcessorTemplateHandler
detecting the start of a new element
(i.e. handling an IOpenElementTag
event).
This method should only be called internally.
void decreaseLevel()
Decrease the context level. This is usually a consequence of the
ProcessorTemplateHandler
detecting the closing of an element
(i.e. handling an ICloseElementTag
event).
This method should only be called internally.
int level()
Return the current context level.
This method should only be called internally.
Copyright © 2016 The THYMELEAF team. All rights reserved.