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

java.lang.Object
  extended byorg.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 Object
implements InternalContextAdapter

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.


Method Summary
 EventCartridge attachEventCartridge(EventCartridge ec)
           
 boolean containsKey(Object key)
          Does the context contain the key
 Object get(String key)
          Get an object from the context, or null if the key is equal to the loop variable
 boolean getAllowRendering()
          Checks to see if rendering should be allowed.
 InternalContextAdapter getBaseContext()
          Returns the base full context impl.
 Resource getCurrentResource()
          temporary fix to enable #include() to figure out current encoding.
 String getCurrentTemplateName()
          get the current template name
 EventCartridge getEventCartridge()
           
 Context getInternalUserContext()
          Returns the wrapped user context.
 Object[] getKeys()
          Get all the keys for the values in the context.
 Object[] getTemplateNameStack()
          Returns the template name stack in form of an array.
 IntrospectionCacheData icacheGet(Object key)
          returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key
 void icachePut(Object key, IntrospectionCacheData o)
          places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key
 Object localPut(String key, Object value)
          Allows callers to explicitly put objects in the local context.
 void popCurrentTemplateName()
          remove the current template name from stack
 void pushCurrentTemplateName(String s)
          set the current template name on top of stack
 Object put(String key, Object value)
          Adds a name/value pair to the context.
 Object remove(Object key)
          Remove an object from the context
 void setAllowRendering(boolean v)
          Set whether rendering is allowed.
 void setCurrentResource(Resource r)
           
 
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
Parameters:
key - The name of the desired value.
Returns:
The value corresponding to the provided key.
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 interface: Context
Adds a name/value pair to the context.

Specified by:
put in interface Context
Parameters:
key - The name to key the provided value with.
value - The corresponding value.
Returns:
The old object or null if there was no old 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
Parameters:
key - name of item to set.
value - object to set to key.
Returns:
old stored object
See Also:
InternalWrapperContext.localPut(String, Object)

containsKey

public boolean containsKey(Object key)
Does the context contain the key

Specified by:
containsKey in interface Context
Parameters:
key - The key to look for.
Returns:
Whether the key is in the context.
See Also:
Context.containsKey(java.lang.Object key)

getKeys

public Object[] getKeys()
Description copied from interface: Context
Get all the keys for the values in the context.

Specified by:
getKeys in interface Context
Returns:
All the keys for the values in the context.
See Also:
Context.getKeys()

remove

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

Specified by:
remove in interface Context
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)

pushCurrentTemplateName

public void pushCurrentTemplateName(String s)
Description copied from interface: org.apache.velocity.context.InternalHousekeepingContext
set the current template name on top of stack

Specified by:
pushCurrentTemplateName in interface org.apache.velocity.context.InternalHousekeepingContext
Parameters:
s - current template name
See Also:
InternalHousekeepingContext.pushCurrentTemplateName(java.lang.String s)

popCurrentTemplateName

public void popCurrentTemplateName()
Description copied from interface: org.apache.velocity.context.InternalHousekeepingContext
remove the current template name from stack

Specified by:
popCurrentTemplateName in interface org.apache.velocity.context.InternalHousekeepingContext
See Also:
InternalHousekeepingContext.popCurrentTemplateName()

getCurrentTemplateName

public String getCurrentTemplateName()
Description copied from interface: org.apache.velocity.context.InternalHousekeepingContext
get the current template name

Specified by:
getCurrentTemplateName in interface org.apache.velocity.context.InternalHousekeepingContext
Returns:
String current template name
See Also:
InternalHousekeepingContext.getCurrentTemplateName()

getTemplateNameStack

public Object[] getTemplateNameStack()
Description copied from interface: org.apache.velocity.context.InternalHousekeepingContext
Returns the template name stack in form of an array.

Specified by:
getTemplateNameStack in interface org.apache.velocity.context.InternalHousekeepingContext
Returns:
Object[] with the template name stack contents.
See Also:
InternalHousekeepingContext.getTemplateNameStack()

icacheGet

public IntrospectionCacheData icacheGet(Object key)
Description copied from interface: org.apache.velocity.context.InternalHousekeepingContext
returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key

Specified by:
icacheGet in interface org.apache.velocity.context.InternalHousekeepingContext
Parameters:
key - key to find in cache
Returns:
cache object
See Also:
InternalHousekeepingContext.icacheGet(java.lang.Object key)

icachePut

public void icachePut(Object key,
                      IntrospectionCacheData o)
Description copied from interface: org.apache.velocity.context.InternalHousekeepingContext
places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key

Specified by:
icachePut in interface org.apache.velocity.context.InternalHousekeepingContext
Parameters:
key - key
o - IntrospectionCacheData object to place in cache
See Also:
InternalHousekeepingContext.icachePut(java.lang.Object key, org.apache.velocity.util.introspection.IntrospectionCacheData o)

setCurrentResource

public void setCurrentResource(Resource r)
Specified by:
setCurrentResource in interface org.apache.velocity.context.InternalHousekeepingContext
Parameters:
r -
See Also:
InternalHousekeepingContext.setCurrentResource(org.apache.velocity.runtime.resource.Resource r)

getCurrentResource

public Resource getCurrentResource()
Description copied from interface: org.apache.velocity.context.InternalHousekeepingContext
temporary fix to enable #include() to figure out current encoding.

Specified by:
getCurrentResource in interface org.apache.velocity.context.InternalHousekeepingContext
Returns:
The current resource.
See Also:
InternalHousekeepingContext.getCurrentResource()

getBaseContext

public InternalContextAdapter getBaseContext()
Description copied from interface: InternalWrapperContext
Returns the base full context impl.

Specified by:
getBaseContext in interface InternalWrapperContext
Returns:
The base full context impl.
See Also:
InternalWrapperContext.getBaseContext()

getInternalUserContext

public Context getInternalUserContext()
Description copied from interface: InternalWrapperContext
Returns the wrapped user context.

Specified by:
getInternalUserContext in interface InternalWrapperContext
Returns:
The wrapped user context.
See Also:
InternalWrapperContext.getInternalUserContext()

attachEventCartridge

public EventCartridge attachEventCartridge(EventCartridge ec)
Specified by:
attachEventCartridge in interface InternalEventContext
Parameters:
ec -
Returns:
The old EventCartridge.
See Also:
InternalEventContext.attachEventCartridge(org.apache.velocity.app.event.EventCartridge ec)

getEventCartridge

public EventCartridge getEventCartridge()
Specified by:
getEventCartridge in interface InternalEventContext
Returns:
The current EventCartridge.
See Also:
InternalEventContext.getEventCartridge()

getAllowRendering

public boolean getAllowRendering()
Description copied from interface: org.apache.velocity.context.InternalHousekeepingContext
Checks to see if rendering should be allowed. Defaults to true but will return false after a #stop directive.

Specified by:
getAllowRendering in interface org.apache.velocity.context.InternalHousekeepingContext
Returns:
true if rendering is allowed, false if no rendering should occur
See Also:
InternalHousekeepingContext.getAllowRendering()

setAllowRendering

public void setAllowRendering(boolean v)
Description copied from interface: org.apache.velocity.context.InternalHousekeepingContext
Set whether rendering is allowed. Defaults to true but is set to false after a #stop directive.

Specified by:
setAllowRendering in interface org.apache.velocity.context.InternalHousekeepingContext
Parameters:
v -
See Also:
InternalHousekeepingContext.setAllowRendering(boolean v)


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