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 ResourcecurrentResourceCurrent resource - used for carrying encoding and other information down into the rendering processprivate EventCartridgeeventCartridgeEventCartridge we are to carry.private java.util.HashMapintrospectionCachecache for node/context specific introspection informationprivate java.util.ListmacroLibrariesList for holding the macro libraries.private java.util.StackmacroNameStackVelocimacro name stack.private static longserialVersionUIDVersion Id for serializableprivate java.util.StacktemplateNameStackTemplate name stack.
-
Constructor Summary
Constructors Constructor Description InternalContextBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventCartridgeattachEventCartridge(EventCartridge ec)intgetCurrentMacroCallDepth()get the current macro call depthjava.lang.StringgetCurrentMacroName()get the current macro nameResourcegetCurrentResource()temporary fix to enable #include() to figure out current encoding.java.lang.StringgetCurrentTemplateName()get the current template nameEventCartridgegetEventCartridge()java.util.ListgetMacroLibraries()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 stackIntrospectionCacheDataicacheGet(java.lang.Object key)returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the keyvoidicachePut(java.lang.Object key, IntrospectionCacheData o)places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified keyvoidpopCurrentMacroName()remove the current macro name from stackvoidpopCurrentTemplateName()remove the current template name from stackvoidpushCurrentMacroName(java.lang.String s)set the current macro name on top of stackvoidpushCurrentTemplateName(java.lang.String s)set the current template name on top of stackvoidsetCurrentResource(Resource r)voidsetMacroLibraries(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:
pushCurrentTemplateNamein interfaceInternalHousekeepingContext- Parameters:
s- current template name
-
popCurrentTemplateName
public void popCurrentTemplateName()
remove the current template name from stack- Specified by:
popCurrentTemplateNamein interfaceInternalHousekeepingContext
-
getCurrentTemplateName
public java.lang.String getCurrentTemplateName()
get the current template name- Specified by:
getCurrentTemplateNamein interfaceInternalHousekeepingContext- Returns:
- String current template name
-
getTemplateNameStack
public java.lang.Object[] getTemplateNameStack()
get the current template name stack- Specified by:
getTemplateNameStackin 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:
pushCurrentMacroNamein interfaceInternalHousekeepingContext- Parameters:
s- current macro name
-
popCurrentMacroName
public void popCurrentMacroName()
remove the current macro name from stack- Specified by:
popCurrentMacroNamein interfaceInternalHousekeepingContext
-
getCurrentMacroName
public java.lang.String getCurrentMacroName()
get the current macro name- Specified by:
getCurrentMacroNamein interfaceInternalHousekeepingContext- Returns:
- String current macro name
-
getCurrentMacroCallDepth
public int getCurrentMacroCallDepth()
get the current macro call depth- Specified by:
getCurrentMacroCallDepthin interfaceInternalHousekeepingContext- Returns:
- int current macro call depth
-
getMacroNameStack
public java.lang.Object[] getMacroNameStack()
get the current macro name stack- Specified by:
getMacroNameStackin 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:
icacheGetin 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:
icachePutin interfaceInternalHousekeepingContext- Parameters:
key- keyo- IntrospectionCacheData object to place in cache
-
setCurrentResource
public void setCurrentResource(Resource r)
- Specified by:
setCurrentResourcein interfaceInternalHousekeepingContext- See Also:
InternalHousekeepingContext.setCurrentResource(org.apache.velocity.runtime.resource.Resource)
-
getCurrentResource
public Resource getCurrentResource()
Description copied from interface:InternalHousekeepingContexttemporary fix to enable #include() to figure out current encoding.- Specified by:
getCurrentResourcein interfaceInternalHousekeepingContext- Returns:
- The current resource.
- See Also:
InternalHousekeepingContext.getCurrentResource()
-
setMacroLibraries
public void setMacroLibraries(java.util.List macroLibraries)
Description copied from interface:InternalHousekeepingContextSet the macro library list for the current template.- Specified by:
setMacroLibrariesin interfaceInternalHousekeepingContext- Parameters:
macroLibraries- list of macro libraries to set- See Also:
InternalHousekeepingContext.setMacroLibraries(List)
-
getMacroLibraries
public java.util.List getMacroLibraries()
Description copied from interface:InternalHousekeepingContextGet the macro library list for the current template.- Specified by:
getMacroLibrariesin interfaceInternalHousekeepingContext- Returns:
- List of macro library names
- See Also:
InternalHousekeepingContext.getMacroLibraries()
-
attachEventCartridge
public EventCartridge attachEventCartridge(EventCartridge ec)
- Specified by:
attachEventCartridgein interfaceInternalEventContext- Returns:
- The old EventCartridge.
- See Also:
InternalEventContext.attachEventCartridge(org.apache.velocity.app.event.EventCartridge)
-
getEventCartridge
public EventCartridge getEventCartridge()
- Specified by:
getEventCartridgein interfaceInternalEventContext- Returns:
- The current EventCartridge.
- See Also:
InternalEventContext.getEventCartridge()
-
-