Package freemarker.core
Interface Scope
-
- All Superinterfaces:
TemplateHashModel,TemplateHashModelEx,TemplateModel
- All Known Implementing Classes:
AbstractScope,BaseScope,BlockScope,Configuration,Environment,IncludedTemplateNamespace,LoopContext,MacroContext,MacroInvocationBodyContext,TemplateNamespace
public interface Scope extends TemplateHashModelEx
Represents a variable resolution context in FTL. This may be the local variables in a macro, the context of a loop or a template namespace
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface freemarker.template.TemplateModel
TemplateModel.InvalidExpressionModel, TemplateModel.JavaNull
-
-
Field Summary
-
Fields inherited from interface freemarker.template.TemplateModel
INVALID_EXPRESSION, JAVA_NULL, NOTHING
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleandefinesVariable(String name)Collection<String>getDirectVariableNames()Returns the names of variables directly managed by this scope (i.e.ScopegetEnclosingScope()EnvironmentgetEnvironment()TemplategetTemplate()voidput(String key, TemplateModel value)Set a variable in this scope.TemplateModelremove(String key)Removes a variable in this scope.TemplateModelresolveVariable(String name)Evaluates the variable of this name in this scope, falling back to the enclosing Scope if it is not defined in this one.-
Methods inherited from interface freemarker.template.TemplateHashModel
get, isEmpty
-
Methods inherited from interface freemarker.template.TemplateHashModelEx
keys, size, values
-
-
-
-
Method Detail
-
put
void put(String key, TemplateModel value)
Set a variable in this scope. This will typically only be used internally by the FreeMarker engine.
-
remove
TemplateModel remove(String key)
Removes a variable in this scope. This will typically only be used by FreeMarker engine internals
-
getEnvironment
Environment getEnvironment()
- Returns:
- the Environment object associated with this Scope.
-
getTemplate
Template getTemplate()
- Returns:
- the Template object associated with this Scope.
-
definesVariable
boolean definesVariable(String name)
- Returns:
- whether the variable is defined in this specific scope. (It could be defined in a fallback scope and this method will return false.)
-
getEnclosingScope
Scope getEnclosingScope()
- Returns:
- the fallback Scope for variable resolution
-
resolveVariable
TemplateModel resolveVariable(String name) throws TemplateModelException
Evaluates the variable of this name in this scope, falling back to the enclosing Scope if it is not defined in this one.- Throws:
TemplateModelException
-
getDirectVariableNames
Collection<String> getDirectVariableNames() throws TemplateModelException
Returns the names of variables directly managed by this scope (i.e. it does not traverse the chain of enclosing scopes, but limits itself to this scope only).- Returns:
- a collection of known variable names for this scope, without enclosing scopes. The returned collection should be either immutable, or it should be disconnected from the scope, so any modifications to the collection don't affect the scope.
- Throws:
TemplateModelException
-
-