Package org.apache.velocity.context
Class InternalContextBase
- java.lang.Object
-
- org.apache.velocity.context.InternalContextBase
-
- All Implemented Interfaces:
InternalEventContext
,InternalHousekeepingContext
- Direct Known Subclasses:
AbstractContext
class InternalContextBase extends java.lang.Object implements InternalHousekeepingContext, InternalEventContext
class to encapsulate the 'stuff' for internal operation of velocity. We use the context as a thread-safe storage : we take advantage of the fact that it's a visitor of sorts to all nodes (that matter) of the AST during init() and render(). Currently, it carries the template name for namespace support, as well as node-local context data introspection caching. Note that this is not a public class. It is for package access only to keep application code from accessing the internals, as AbstractContext is derived from this.- Version:
- $Id: InternalContextBase.java 731266 2009-01-04 15:11:20Z byron $
-
-
Field Summary
Fields Modifier and Type Field Description private Resource
currentResource
Current resource - used for carrying encoding and other information down into the rendering processprivate EventCartridge
eventCartridge
EventCartridge we are to carry.private java.util.HashMap
introspectionCache
cache for node/context specific introspection informationprivate java.util.List
macroLibraries
List for holding the macro libraries.private java.util.Stack
macroNameStack
Velocimacro name stack.private static long
serialVersionUID
Version Id for serializableprivate java.util.Stack
templateNameStack
Template name stack.
-
Constructor Summary
Constructors Constructor Description InternalContextBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventCartridge
attachEventCartridge(EventCartridge ec)
int
getCurrentMacroCallDepth()
get the current macro call depthjava.lang.String
getCurrentMacroName()
get the current macro nameResource
getCurrentResource()
temporary fix to enable #include() to figure out current encoding.java.lang.String
getCurrentTemplateName()
get the current template nameEventCartridge
getEventCartridge()
java.util.List
getMacroLibraries()
Get the macro library list for the current template.java.lang.Object[]
getMacroNameStack()
get the current macro name stackjava.lang.Object[]
getTemplateNameStack()
get the current template name stackIntrospectionCacheData
icacheGet(java.lang.Object key)
returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the keyvoid
icachePut(java.lang.Object key, IntrospectionCacheData o)
places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified keyvoid
popCurrentMacroName()
remove the current macro name from stackvoid
popCurrentTemplateName()
remove the current template name from stackvoid
pushCurrentMacroName(java.lang.String s)
set the current macro name on top of stackvoid
pushCurrentTemplateName(java.lang.String s)
set the current template name on top of stackvoid
setCurrentResource(Resource r)
void
setMacroLibraries(java.util.List macroLibraries)
Set the macro library list for the current template.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Version Id for serializable- See Also:
- Constant Field Values
-
introspectionCache
private java.util.HashMap introspectionCache
cache for node/context specific introspection information
-
templateNameStack
private java.util.Stack templateNameStack
Template name stack. The stack top contains the current template name.
-
macroNameStack
private java.util.Stack macroNameStack
Velocimacro name stack. The stack top contains the current macro name.
-
eventCartridge
private EventCartridge eventCartridge
EventCartridge we are to carry. Set by application
-
currentResource
private Resource currentResource
Current resource - used for carrying encoding and other information down into the rendering process
-
macroLibraries
private java.util.List macroLibraries
List for holding the macro libraries. Contains the macro library template name as strings.
-
-
Method Detail
-
pushCurrentTemplateName
public void pushCurrentTemplateName(java.lang.String s)
set the current template name on top of stack- Specified by:
pushCurrentTemplateName
in interfaceInternalHousekeepingContext
- Parameters:
s
- current template name
-
popCurrentTemplateName
public void popCurrentTemplateName()
remove the current template name from stack- Specified by:
popCurrentTemplateName
in interfaceInternalHousekeepingContext
-
getCurrentTemplateName
public java.lang.String getCurrentTemplateName()
get the current template name- Specified by:
getCurrentTemplateName
in interfaceInternalHousekeepingContext
- Returns:
- String current template name
-
getTemplateNameStack
public java.lang.Object[] getTemplateNameStack()
get the current template name stack- Specified by:
getTemplateNameStack
in interfaceInternalHousekeepingContext
- Returns:
- Object[] with the template name stack contents.
-
pushCurrentMacroName
public void pushCurrentMacroName(java.lang.String s)
set the current macro name on top of stack- Specified by:
pushCurrentMacroName
in interfaceInternalHousekeepingContext
- Parameters:
s
- current macro name
-
popCurrentMacroName
public void popCurrentMacroName()
remove the current macro name from stack- Specified by:
popCurrentMacroName
in interfaceInternalHousekeepingContext
-
getCurrentMacroName
public java.lang.String getCurrentMacroName()
get the current macro name- Specified by:
getCurrentMacroName
in interfaceInternalHousekeepingContext
- Returns:
- String current macro name
-
getCurrentMacroCallDepth
public int getCurrentMacroCallDepth()
get the current macro call depth- Specified by:
getCurrentMacroCallDepth
in interfaceInternalHousekeepingContext
- Returns:
- int current macro call depth
-
getMacroNameStack
public java.lang.Object[] getMacroNameStack()
get the current macro name stack- Specified by:
getMacroNameStack
in interfaceInternalHousekeepingContext
- Returns:
- Object[] with the macro name stack contents.
-
icacheGet
public IntrospectionCacheData icacheGet(java.lang.Object key)
returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key- Specified by:
icacheGet
in interfaceInternalHousekeepingContext
- Parameters:
key
- key to find in cache- Returns:
- cache object
-
icachePut
public void icachePut(java.lang.Object key, IntrospectionCacheData o)
places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key- Specified by:
icachePut
in interfaceInternalHousekeepingContext
- Parameters:
key
- keyo
- IntrospectionCacheData object to place in cache
-
setCurrentResource
public void setCurrentResource(Resource r)
- Specified by:
setCurrentResource
in interfaceInternalHousekeepingContext
- See Also:
InternalHousekeepingContext.setCurrentResource(org.apache.velocity.runtime.resource.Resource)
-
getCurrentResource
public Resource getCurrentResource()
Description copied from interface:InternalHousekeepingContext
temporary fix to enable #include() to figure out current encoding.- Specified by:
getCurrentResource
in interfaceInternalHousekeepingContext
- Returns:
- The current resource.
- See Also:
InternalHousekeepingContext.getCurrentResource()
-
setMacroLibraries
public void setMacroLibraries(java.util.List macroLibraries)
Description copied from interface:InternalHousekeepingContext
Set the macro library list for the current template.- Specified by:
setMacroLibraries
in interfaceInternalHousekeepingContext
- Parameters:
macroLibraries
- list of macro libraries to set- See Also:
InternalHousekeepingContext.setMacroLibraries(List)
-
getMacroLibraries
public java.util.List getMacroLibraries()
Description copied from interface:InternalHousekeepingContext
Get the macro library list for the current template.- Specified by:
getMacroLibraries
in interfaceInternalHousekeepingContext
- Returns:
- List of macro library names
- See Also:
InternalHousekeepingContext.getMacroLibraries()
-
attachEventCartridge
public EventCartridge attachEventCartridge(EventCartridge ec)
- Specified by:
attachEventCartridge
in interfaceInternalEventContext
- Returns:
- The old EventCartridge.
- See Also:
InternalEventContext.attachEventCartridge(org.apache.velocity.app.event.EventCartridge)
-
getEventCartridge
public EventCartridge getEventCartridge()
- Specified by:
getEventCartridge
in interfaceInternalEventContext
- Returns:
- The current EventCartridge.
- See Also:
InternalEventContext.getEventCartridge()
-
-