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 Resource
Current resource - used for carrying encoding and other information down into the rendering processprivate EventCartridge
EventCartridge 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 long
Version Id for serializableTemplate name stack. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
get 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 keyvoid
icachePut
(Object key, IntrospectionCacheData o) places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified keyvoid
remove the current macro name from stackvoid
remove the current template name from stackvoid
set the current macro name on top of stackvoid
set the current template name on top of stackvoid
void
setMacroLibraries
(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:
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
get the current template name- Specified by:
getCurrentTemplateName
in interfaceInternalHousekeepingContext
- Returns:
- String current template name
-
getTemplateNameStack
get the current template name stack- Specified by:
getTemplateNameStack
in interfaceInternalHousekeepingContext
- Returns:
- String[] with the template name stack contents.
-
pushCurrentMacroName
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
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
get the current macro name stack- Specified by:
getMacroNameStack
in interfaceInternalHousekeepingContext
- Returns:
- String[] with the macro name stack contents.
-
icacheGet
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
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
- Specified by:
setCurrentResource
in interfaceInternalHousekeepingContext
- See Also:
-
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:
-
setMacroLibraries
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:
-
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:
-
attachEventCartridge
- Specified by:
attachEventCartridge
in interfaceInternalEventContext
- Returns:
- The old EventCartridge.
- See Also:
-
getEventCartridge
- Specified by:
getEventCartridge
in interfaceInternalEventContext
- Returns:
- The current EventCartridge.
- See Also:
-