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 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$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ResourceCurrent resource - used for carrying encoding and other information down into the rendering processprivate EventCartridgeEventCartridge we are to carry.private Map<Object, IntrospectionCacheData> cache for node/context specific introspection informationList for holding the macro libraries.Velocimacro name stack.private static final longVersion Id for serializableTemplate name stack. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintget the current macro call depthget the current macro nametemporary fix to enable #include() to figure out current encoding.get the current template nameGet the macro library list for the current template.String[]get the current macro name stackString[]get the current template name stackreturns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the keyvoidicachePut(Object key, IntrospectionCacheData o) places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified keyvoidremove the current macro name from stackvoidremove the current template name from stackvoidset the current macro name on top of stackvoidset the current template name on top of stackvoidvoidsetMacroLibraries(List<Template> macroLibraries) Set the macro library list for the current template.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDVersion Id for serializable- See Also:
-
introspectionCache
cache for node/context specific introspection information -
templateNameStack
Template name stack. The stack top contains the current template name. -
macroNameStack
Velocimacro name stack. The stack top contains the current macro name. -
eventCartridge
EventCartridge we are to carry. Set by application -
currentResource
Current resource - used for carrying encoding and other information down into the rendering process -
macroLibraries
List for holding the macro libraries. Contains the macro library template name as strings.
-
-
Constructor Details
-
InternalContextBase
InternalContextBase()
-
-
Method Details
-
pushCurrentTemplateName
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
get the current template name- Specified by:
getCurrentTemplateNamein interfaceInternalHousekeepingContext- Returns:
- String current template name
-
getTemplateNameStack
get the current template name stack- Specified by:
getTemplateNameStackin interfaceInternalHousekeepingContext- Returns:
- String[] with the template name stack contents.
-
pushCurrentMacroName
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
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
get the current macro name stack- Specified by:
getMacroNameStackin interfaceInternalHousekeepingContext- Returns:
- String[] with the macro name stack contents.
-
icacheGet
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
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
- Specified by:
setCurrentResourcein interfaceInternalHousekeepingContext- Parameters:
r-- See Also:
-
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:
-
setMacroLibraries
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:
-
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:
-
attachEventCartridge
- Specified by:
attachEventCartridgein interfaceInternalEventContext- Parameters:
ec-- Returns:
- The old EventCartridge.
- See Also:
-
getEventCartridge
- Specified by:
getEventCartridgein interfaceInternalEventContext- Returns:
- The current EventCartridge.
- See Also:
-