org.apache.velocity.context
Class InternalContextBase

java.lang.Object
  |
  +--org.apache.velocity.context.InternalContextBase
All Implemented Interfaces:
InternalHousekeepingContext, java.io.Serializable
Direct Known Subclasses:
AbstractContext

class InternalContextBase
extends java.lang.Object
implements InternalHousekeepingContext, java.io.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.5 2001/03/05 11:21:43 jvanzyl Exp $
Author:
Geir Magnusson Jr.
See Also:
Serialized Form

Field Summary
private  java.util.HashMap introspectionCache
          cache for node/context specific introspection information
private  java.util.Stack templateNameStack
          Template name stack.
 
Constructor Summary
(package private) InternalContextBase()
           
 
Method Summary
 java.lang.String getCurrentTemplateName()
          get the current template name
 java.lang.Object[] getTemplateNameStack()
          get the current template name stack
 IntrospectionCacheData icacheGet(java.lang.Object key)
          returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key
 void icachePut(java.lang.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(java.lang.String s)
          set the current template name on top of stack
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

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.
Constructor Detail

InternalContextBase

InternalContextBase()
Method Detail

pushCurrentTemplateName

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

popCurrentTemplateName

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

getCurrentTemplateName

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

getTemplateNameStack

public java.lang.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(java.lang.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(java.lang.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


Copyright © 2001 Apache Software Foundation. All Rights Reserved.