org.apache.velocity.context

Class InternalContextBase

Implemented Interfaces:
InternalEventContext, InternalHousekeepingContext, Serializable
Known Direct Subclasses:
AbstractContext

(package private) class InternalContextBase
extends java.lang.Object
implements InternalHousekeepingContext, InternalEventContext, Serializable

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,v 1.8.12.1 2004/03/03 23:22:54 geirm Exp $

Author:
Geir Magnusson Jr.

Field Summary

private Resource
currentResource
Current resource - used for carrying encoding and other information down into the rendering process
private EventCartridge
eventCartridge
EventCartridge we are to carry.
private HashMap
introspectionCache
cache for node/context specific introspection information
private Stack
templateNameStack
Template name stack.

Method Summary

EventCartridge
attachEventCartridge(EventCartridge ec)
Resource
getCurrentResource()
temporary fix to enable #include() to figure out current encoding.
String
getCurrentTemplateName()
get the current template name
EventCartridge
getEventCartridge()
Object[]
getTemplateNameStack()
get the current template name stack
IntrospectionCacheData
icacheGet(Object key)
returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key
void
icachePut(Object key, IntrospectionCacheData o)
places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key
void
popCurrentTemplateName()
remove the current template name from stack
void
pushCurrentTemplateName(String s)
set the current template name on top of stack
void
setCurrentResource(Resource r)

Field Details

currentResource

private Resource currentResource
Current resource - used for carrying encoding and other information down into the rendering process


eventCartridge

private EventCartridge eventCartridge
EventCartridge we are to carry. Set by application


introspectionCache

private HashMap introspectionCache
cache for node/context specific introspection information


templateNameStack

private Stack templateNameStack
Template name stack. The stack top contains the current template name.

Method Details

attachEventCartridge

public EventCartridge attachEventCartridge(EventCartridge ec)
Specified by:
attachEventCartridge in interface InternalEventContext


getCurrentResource

public Resource getCurrentResource()
temporary fix to enable #include() to figure out current encoding.
Specified by:
getCurrentResource in interface InternalHousekeepingContext


getCurrentTemplateName

public String getCurrentTemplateName()
get the current template name
Specified by:
getCurrentTemplateName in interface InternalHousekeepingContext

Returns:
String current template name


getEventCartridge

public EventCartridge getEventCartridge()
Specified by:
getEventCartridge in interface InternalEventContext


getTemplateNameStack

public Object[] getTemplateNameStack()
get the current template name stack
Specified by:
getTemplateNameStack in interface InternalHousekeepingContext

Returns:
Object[] with the template name stack contents.


icacheGet

public IntrospectionCacheData icacheGet(Object key)
returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key
Specified by:
icacheGet in interface InternalHousekeepingContext

Parameters:
key - key to find in cache

Returns:
cache object


icachePut

public void icachePut(Object key,
                      IntrospectionCacheData o)
places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key
Specified by:
icachePut in interface InternalHousekeepingContext

Parameters:
key - key
o - IntrospectionCacheData object to place in cache


popCurrentTemplateName

public void popCurrentTemplateName()
remove the current template name from stack
Specified by:
popCurrentTemplateName in interface InternalHousekeepingContext


pushCurrentTemplateName

public void pushCurrentTemplateName(String s)
set the current template name on top of stack
Specified by:
pushCurrentTemplateName in interface InternalHousekeepingContext

Parameters:
s - current template name


setCurrentResource

public void setCurrentResource(Resource r)
Specified by:
setCurrentResource in interface InternalHousekeepingContext


Copyright B) 2002 Apache Software Foundation. All Rights Reserved.