org.apache.velocity.runtime.directive
Class Foreach.NullHolderContext

java.lang.Object
  extended by org.apache.velocity.context.ChainedInternalContextAdapter
      extended by org.apache.velocity.runtime.directive.Foreach.NullHolderContext
All Implemented Interfaces:
Context, InternalContextAdapter, InternalEventContext, InternalWrapperContext
Enclosing class:
Foreach

protected static class Foreach.NullHolderContext
extends ChainedInternalContextAdapter

A special context to use when the foreach iterator returns a null. This is required since the standard context may not support nulls. All puts and gets are passed through, except for the foreach iterator key.

Since:
1.5

Field Summary
 
Fields inherited from class org.apache.velocity.context.ChainedInternalContextAdapter
innerContext
 
Method Summary
 Object get(String key)
          Get an object from the context, or null if the key is equal to the loop variable
 Object localPut(String key, Object value)
          Allows callers to explicitly put objects in the local context.
 Object put(String key, Object value)
          Put method also stores values in parent context
 Object remove(Object key)
          Remove an object from the context
 
Methods inherited from class org.apache.velocity.context.ChainedInternalContextAdapter
attachEventCartridge, containsKey, getAllowRendering, getBaseContext, getCurrentMacroCallDepth, getCurrentMacroName, getCurrentResource, getCurrentTemplateName, getEventCartridge, getInternalUserContext, getKeys, getMacroLibraries, getMacroNameStack, getTemplateNameStack, icacheGet, icachePut, popCurrentMacroName, popCurrentTemplateName, pushCurrentMacroName, pushCurrentTemplateName, setAllowRendering, setCurrentResource, setMacroLibraries
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public Object get(String key)
           throws MethodInvocationException
Get an object from the context, or null if the key is equal to the loop variable

Specified by:
get in interface Context
Overrides:
get in class ChainedInternalContextAdapter
Parameters:
key - name of item to get
Returns:
stored object or null
Throws:
MethodInvocationException - passes on potential exception from reference method call
See Also:
Context.get(java.lang.String)

put

public Object put(String key,
                  Object value)
Description copied from class: ChainedInternalContextAdapter
Put method also stores values in parent context

Specified by:
put in interface Context
Overrides:
put in class ChainedInternalContextAdapter
Parameters:
key - name of item to set
value - object to set to key
Returns:
old stored object
See Also:
Context.put(java.lang.String key, java.lang.Object value)

localPut

public Object localPut(String key,
                       Object value)
Allows callers to explicitly put objects in the local context. Objects added to the context through this method always end up in the top-level context of possible wrapped contexts.

Specified by:
localPut in interface InternalWrapperContext
Overrides:
localPut in class ChainedInternalContextAdapter
Parameters:
key - name of item to set.
value - object to set to key.
Returns:
old stored object
See Also:
InternalWrapperContext.localPut(String, Object)

remove

public Object remove(Object key)
Remove an object from the context

Specified by:
remove in interface Context
Overrides:
remove in class ChainedInternalContextAdapter
Parameters:
key - The name of the value to remove.
Returns:
The value that the key was mapped to, or null if unmapped.
See Also:
Context.remove(java.lang.Object key)


Copyright © 2000-2008 The Apache Software Foundation. All Rights Reserved.