org.apache.velocity
Class VelocityContext

java.lang.Object
  |
  +--org.apache.velocity.context.InternalContextBase
        |
        +--org.apache.velocity.context.AbstractContext
              |
              +--org.apache.velocity.VelocityContext
All Implemented Interfaces:
java.lang.Cloneable, Context, InternalEventContext, InternalHousekeepingContext, java.io.Serializable

public class VelocityContext
extends AbstractContext
implements java.lang.Cloneable

General purpose implemention of the application Context interface for general application use. This class should be used in place of the original Context class. This implementation uses a HashMap (@see java.util.HashMap ) for data storage. This context implementation cannot be shared between threads without those threads synchronizing access between them, as the HashMap is not synchronized, nor are some of the fundamentals of AbstractContext. If you need to share a Context between threads with simultaneous access for some reason, please create your own and extend the interface Context

Version:
$Id: VelocityContext.java,v 1.4 2001/03/19 22:32:49 geirm Exp $
Author:
Geir Magnusson Jr., Jason van Zyl, Fedor Karpelevitch
See Also:
Context, Serialized Form

Field Summary
private  java.util.HashMap context
          storage for key/value pairs
 
Fields inherited from class org.apache.velocity.context.AbstractContext
innerContext
 
Fields inherited from class org.apache.velocity.context.InternalContextBase
currentResource, eventCartridge, introspectionCache, templateNameStack
 
Constructor Summary
VelocityContext()
          default contructor, does nothing interesting
VelocityContext(Context innerContext)
          Chaining constructor, used when you want to wrap a context in another.
 
Method Summary
 java.lang.Object clone()
          Clones this context object
 boolean internalContainsKey(java.lang.Object key)
          determines if there is a value for the given key
 java.lang.Object internalGet(java.lang.String key)
          retrieves value for key from internal storage
 java.lang.Object[] internalGetKeys()
          returns array of keys
 java.lang.Object internalPut(java.lang.String key, java.lang.Object value)
          stores the value for key to internal storage
 java.lang.Object internalRemove(java.lang.Object key)
          remove a key/value pair from the internal storage
 
Methods inherited from class org.apache.velocity.context.AbstractContext
containsKey, get, getChainedContext, getKeys, put, remove
 
Methods inherited from class org.apache.velocity.context.InternalContextBase
attachEventCartridge, getCurrentResource, getCurrentTemplateName, getEventCartridge, getTemplateNameStack, icacheGet, icachePut, popCurrentTemplateName, pushCurrentTemplateName, setCurrentResource
 
Methods inherited from class java.lang.Object
, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

context

private java.util.HashMap context
storage for key/value pairs
Constructor Detail

VelocityContext

public VelocityContext()
default contructor, does nothing interesting

VelocityContext

public VelocityContext(Context innerContext)
Chaining constructor, used when you want to wrap a context in another. The inner context will be 'read only' - put() calls to the wrapping context will only effect the outermost context
Parameters:
innerContext - context impl to wrap
Method Detail

internalGet

public java.lang.Object internalGet(java.lang.String key)
retrieves value for key from internal storage
Overrides:
internalGet in class AbstractContext
Parameters:
key - name of value to get
Returns:
value as object

internalPut

public java.lang.Object internalPut(java.lang.String key,
                                    java.lang.Object value)
stores the value for key to internal storage
Overrides:
internalPut in class AbstractContext
Parameters:
key - name of value to store
value - value to store
Returns:
previous value of key as Object

internalContainsKey

public boolean internalContainsKey(java.lang.Object key)
determines if there is a value for the given key
Overrides:
internalContainsKey in class AbstractContext
Parameters:
key - name of value to check
Returns:
true if non-null value in store

internalGetKeys

public java.lang.Object[] internalGetKeys()
returns array of keys
Overrides:
internalGetKeys in class AbstractContext
Returns:
keys as []

internalRemove

public java.lang.Object internalRemove(java.lang.Object key)
remove a key/value pair from the internal storage
Overrides:
internalRemove in class AbstractContext
Parameters:
key - name of value to remove
Returns:
value removed

clone

public java.lang.Object clone()
Clones this context object
Overrides:
clone in class java.lang.Object
Returns:
Object an instance of this Context


Copyright © 2001 Apache Software Foundation. All Rights Reserved.