| java.lang.Object org.apache.velocity.context.InternalContextBase org.apache.velocity.context.AbstractContext
All known Subclasses: org.apache.velocity.VelocityContext,
AbstractContext | abstract public class AbstractContext extends InternalContextBase implements Context(Code) | | This class is the abstract base class for all conventional
Velocity Context implementations. Simply extend this class
and implement the abstract routines that access your preferred
storage method.
Takes care of context chaining.
Also handles / enforces policy on null keys and values :
- Null keys and values are accepted and basically dropped.
- If you place an object into the context with a null key, it
will be ignored and logged.
- If you try to place a null into the context with any key, it
will be dropped and logged.
The default implementation of this for application use is
org.apache.velocity.VelocityContext.
All thanks to Fedor for the chaining idea.
author: Geir Magnusson Jr. author: Fedor Karpelevitch author: Jason van Zyl version: $Id: AbstractContext.java 463298 2006-10-12 16:10:32Z henning $ |
Method Summary | |
public boolean | containsKey(Object key) Indicates whether the specified key is in the context. | public Object | get(String key) Gets the value corresponding to the provided key from the context.
Supports the chaining context mechanism. | public Context | getChainedContext() | public Object[] | getKeys() Get all the keys for the values in the context
Object[] of keys in the Context. | abstract public boolean | internalContainsKey(Object key) Implement to determine if a key is in the storage. | abstract public Object | internalGet(String key) Implement to return a value from the context storage. | abstract public Object[] | internalGetKeys() Implement to return an object array of key
strings from your storage. | abstract public Object | internalPut(String key, Object value) Implement to put a value into the context storage. | abstract public Object | internalRemove(Object key) I mplement to remove an item from your storage. | public Object | put(String key, Object value) Adds a name/value pair to the context.
Parameters: key - The name to key the provided value with. Parameters: value - The corresponding value. | public Object | remove(Object key) Removes the value associated with the specified key from the context.
Parameters: key - The name of the value to remove. |
AbstractContext | public AbstractContext()(Code) | | default CTOR
|
AbstractContext | public AbstractContext(Context inner)(Code) | | Chaining constructor accepts a Context argument.
It will relay get() operations into this Context
in the even the 'local' get() returns null.
Parameters: inner - context to be chained |
containsKey | public boolean containsKey(Object key)(Code) | | Indicates whether the specified key is in the context. Provided for
debugging purposes.
Parameters: key - The key to look for. true if the key is in the context, false if not. |
get | public Object get(String key)(Code) | | Gets the value corresponding to the provided key from the context.
Supports the chaining context mechanism. If the 'local' context
doesn't have the value, we try to get it from the chained context.
Parameters: key - The name of the desired value. The value corresponding to the provided key or null ifthe key param is null. |
getChainedContext | public Context getChainedContext()(Code) | | returns innerContext if one is chained
Context if chained, null if not |
getKeys | public Object[] getKeys()(Code) | | Get all the keys for the values in the context
Object[] of keys in the Context. Does not returnkeys in chained context. |
internalContainsKey | abstract public boolean internalContainsKey(Object key)(Code) | | Implement to determine if a key is in the storage.
Currently, this method is not used internally by
the Velocity engine.
Parameters: key - key to test for existance true if found, false if not |
internalGet | abstract public Object internalGet(String key)(Code) | | Implement to return a value from the context storage.
The implementation of this method is required for proper
operation of a Context implementation in general
Velocity use.
Parameters: key - key whose associated value is to be returned object stored in the context |
internalGetKeys | abstract public Object[] internalGetKeys()(Code) | | Implement to return an object array of key
strings from your storage.
Currently, this method is not used internally by
the Velocity engine.
array of keys |
internalPut | abstract public Object internalPut(String key, Object value)(Code) | | Implement to put a value into the context storage.
The implementation of this method is required for
proper operation of a Context implementation in
general Velocity use.
Parameters: key - key with which to associate the value Parameters: value - value to be associated with the key previously stored value if exists, or null |
internalRemove | abstract public Object internalRemove(Object key)(Code) | | I mplement to remove an item from your storage.
Currently, this method is not used internally by
the Velocity engine.
Parameters: key - key to remove object removed if exists, else null |
put | public Object put(String key, Object value)(Code) | | Adds a name/value pair to the context.
Parameters: key - The name to key the provided value with. Parameters: value - The corresponding value. Object that was replaced in the the Context ifapplicable or null if not. |
remove | public Object remove(Object key)(Code) | | Removes the value associated with the specified key from the context.
Parameters: key - The name of the value to remove. The value that the key was mapped to, or null if unmapped. |
|
|