Foreach.NullHolderContext (Velocity 1.7 API)
Keywords: org.apache.velocity.runtime.directive.Foreach.NullHolderContext class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

    java.lang.Object
      org.apache.velocity.context.ChainedInternalContextAdapter
          org.apache.velocity.runtime.directive.Foreach.NullHolderContext

All Implemented Interfaces:
  Context, InternalContextAdapter, InternalEventContext, org.apache.velocity.context.InternalHousekeepingContext, 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, getBaseContext, getCurrentMacroCallDepth, getCurrentMacroName, getCurrentResource, getCurrentTemplateName, getEventCartridge, getInternalUserContext, getKeys, getMacroLibraries, getMacroNameStack, getTemplateNameStack, icacheGet, icachePut, popCurrentMacroName, popCurrentTemplateName, pushCurrentMacroName, pushCurrentTemplateName, 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.
  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`
  See Also:
    `Context.remove(java.lang.Object key)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.