org.apache.velocity
public class: VelocityContext [javadoc |
source]
java.lang.Object
org.apache.velocity.context.InternalContextBase
org.apache.velocity.context.AbstractContext
org.apache.velocity.VelocityContext
All Implemented Interfaces:
Cloneable, Context, InternalHousekeepingContext, InternalEventContext
Direct Known Subclasses:
ChainedContext, ToolboxContext
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
Also see:
- org.apache.velocity.context.Context
- author:
< - a href="mailto:geirm@optonline.net">Geir Magnusson Jr.
- author:
< - a href="mailto:jvanzyl@apache.org">Jason van Zyl
- author:
< - a href="mailto:fedor.karpelevitch@home.com">Fedor Karpelevitch
- author:
< - a href="mailto:dlr@finemaltcoding.com">Daniel Rall
- version:
$ - Id: VelocityContext.java 463298 2006-10-12 16:10:32Z henning $
| Constructor: |
public VelocityContext() {
this(null, null);
}
Creates a new instance (with no inner context). |
public VelocityContext(Map context) {
this(context, null);
}
Creates a new instance with the provided storage (and no inner
context). |
public VelocityContext(Context innerContext) {
this(null, 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 - The Context implementation to
wrap.
|
public VelocityContext(Map context,
Context innerContext) {
super(innerContext);
this.context = (context == null ? new HashMap() : context);
}
Initializes internal storage (never to null), and
inner context. Parameters:
context - Internal storage, or null to
create default storage.
innerContext - Inner context.
|
| Methods from org.apache.velocity.context.AbstractContext: |
|---|
|
containsKey, get, getChainedContext, getKeys, internalContainsKey, internalGet, internalGetKeys, internalPut, internalRemove, put, remove |
| Methods from org.apache.velocity.context.InternalContextBase: |
|---|
|
attachEventCartridge, getAllowRendering, getCurrentResource, getCurrentTemplateName, getEventCartridge, getTemplateNameStack, icacheGet, icachePut, popCurrentTemplateName, pushCurrentTemplateName, setAllowRendering, setCurrentResource |
| Method from org.apache.velocity.VelocityContext Detail: |
public Object clone() {
VelocityContext clone = null;
try
{
clone = (VelocityContext) super.clone();
clone.context = new HashMap(context);
}
catch (CloneNotSupportedException ignored)
{
}
return clone;
}
Clones this context object. |
public boolean internalContainsKey(Object key) {
return context.containsKey( key );
}
determines if there is a value for the
given key |
public Object internalGet(String key) {
return context.get( key );
}
retrieves value for key from internal
storage |
public Object[] internalGetKeys() {
return context.keySet().toArray();
}
|
public Object internalPut(String key,
Object value) {
return context.put( key, value );
}
stores the value for key to internal
storage |
public Object internalRemove(Object key) {
return context.remove( key );
}
remove a key/value pair from the
internal storage |