Class Scope
- java.lang.Object
-
- java.util.AbstractMap<java.lang.Object,java.lang.Object>
-
- org.apache.velocity.runtime.directive.Scope
-
- All Implemented Interfaces:
java.util.Map<java.lang.Object,java.lang.Object>
- Direct Known Subclasses:
ForeachScope
public class Scope extends java.util.AbstractMap<java.lang.Object,java.lang.Object>
This handles context scoping and metadata for directives.- Version:
- $Id$
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Scope.Info
Class to encapsulate and provide access to info about the current scope for debugging.
-
Field Summary
Fields Modifier and Type Field Description private Scope.Info
info
protected java.lang.Object
owner
private Scope
parent
private java.lang.Object
replaced
private static java.lang.String
setReturnValue
private java.util.Map<java.lang.Object,java.lang.Object>
storage
-
Constructor Summary
Constructors Constructor Description Scope(java.lang.Object owner, java.lang.Object previous)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>>
entrySet()
java.lang.Object
get(java.lang.Object key)
getterprotected int
getDepth()
Returns the number of control arguments of this type that are stacked up.Scope.Info
getInfo()
Returns info about the current scope for debugging purposes.Scope
getParent()
Returns the parent control reference overridden by the placement of this instance in the context.java.lang.Object
getReplaced()
Returns the user's context reference overridden by the placement of this instance in the context.private java.util.Map<java.lang.Object,java.lang.Object>
getStorage()
Scope
getTopmost()
Returns the topmost parent control reference, retrieved by simple recursion ongetParent()
.java.lang.Object
put(java.lang.Object key, java.lang.Object value)
setterjava.lang.String
set(java.lang.Object key, java.lang.Object value)
Convenience method to call put(key,val) in a template without worrying about what is returned/rendered by the call.protected void
stop()
Allows #stop to easily trigger the proper StopCommand for this scope.-
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
-
-
-
-
Field Detail
-
setReturnValue
private static final java.lang.String setReturnValue
- See Also:
- Constant Field Values
-
storage
private java.util.Map<java.lang.Object,java.lang.Object> storage
-
replaced
private java.lang.Object replaced
-
parent
private Scope parent
-
info
private Scope.Info info
-
owner
protected final java.lang.Object owner
-
-
Method Detail
-
getStorage
private java.util.Map<java.lang.Object,java.lang.Object> getStorage()
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<java.lang.Object,java.lang.Object>
- Specified by:
entrySet
in classjava.util.AbstractMap<java.lang.Object,java.lang.Object>
- Returns:
- entry set
-
get
public java.lang.Object get(java.lang.Object key)
getter- Specified by:
get
in interfacejava.util.Map<java.lang.Object,java.lang.Object>
- Overrides:
get
in classjava.util.AbstractMap<java.lang.Object,java.lang.Object>
- Parameters:
key
-- Returns:
- found value
-
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
setter- Specified by:
put
in interfacejava.util.Map<java.lang.Object,java.lang.Object>
- Overrides:
put
in classjava.util.AbstractMap<java.lang.Object,java.lang.Object>
- Parameters:
key
-value
-- Returns:
- previous value
-
set
public java.lang.String set(java.lang.Object key, java.lang.Object value)
Convenience method to call put(key,val) in a template without worrying about what is returned/rendered by the call. This should ALWAYS return an empty string.- Parameters:
key
-value
-- Returns:
- empty string
-
stop
protected void stop()
Allows #stop to easily trigger the proper StopCommand for this scope.
-
getDepth
protected int getDepth()
Returns the number of control arguments of this type that are stacked up. This is the distance between this instance and the topmost instance, plus one. This value will never be negative or zero.- Returns:
- depth
-
getTopmost
public Scope getTopmost()
Returns the topmost parent control reference, retrieved by simple recursion ongetParent()
.- Returns:
- top-most scope
-
getParent
public Scope getParent()
Returns the parent control reference overridden by the placement of this instance in the context.- Returns:
- parent scope
-
getReplaced
public java.lang.Object getReplaced()
Returns the user's context reference overridden by the placement of this instance in the context. If there was none (as is hoped), then this will return null. This never returns parent controls; those are returned bygetParent()
.- Returns:
- replaced reference value, or null
-
getInfo
public Scope.Info getInfo()
Returns info about the current scope for debugging purposes.- Returns:
- template debugging infos
-
-