Package org.apache.velocity.context
Class ChainedInternalContextAdapter
- java.lang.Object
-
- org.apache.velocity.context.ChainedInternalContextAdapter
-
- All Implemented Interfaces:
Context,InternalContextAdapter,InternalEventContext,InternalHousekeepingContext,InternalWrapperContext
- Direct Known Subclasses:
EvaluateContext,Foreach.NullHolderContext,ProxyVMContext
public abstract class ChainedInternalContextAdapter extends java.lang.Object implements InternalContextAdapter
This is an abstract internal-use-only context implementation to be used as a subclass for other internal-use-only contexts that wrap other internal-use-only contexts. We use this context to make it easier to chain an existing context as part of a new context implementation. It just delegates everything to the inner/parent context. Subclasses then only need to override the methods relevant to them.- Since:
- 1.6
- Version:
- $Id: ChainedInternalContextAdapter.java 685724 2008-08-13 23:12:12Z nbubna $
-
-
Field Summary
Fields Modifier and Type Field Description protected InternalContextAdapterinnerContextthe parent context
-
Constructor Summary
Constructors Constructor Description ChainedInternalContextAdapter(InternalContextAdapter inner)CTOR, wraps an ICA
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventCartridgeattachEventCartridge(EventCartridge ec)booleancontainsKey(java.lang.Object key)Indicates whether the specified key is in the context.java.lang.Objectget(java.lang.String key)Retrieves from parent context.InternalContextAdaptergetBaseContext()Returns the base full context impl.intgetCurrentMacroCallDepth()get the current macro call depthjava.lang.StringgetCurrentMacroName()get the current macro nameResourcegetCurrentResource()temporary fix to enable #include() to figure out current encoding.java.lang.StringgetCurrentTemplateName()get the current template nameEventCartridgegetEventCartridge()ContextgetInternalUserContext()Return the inner / user context.java.lang.Object[]getKeys()Get all the keys for the values in the context.java.util.ListgetMacroLibraries()Get the macro library list for the current template.java.lang.Object[]getMacroNameStack()Returns the macro name stack in form of an array.java.lang.Object[]getTemplateNameStack()Returns the template name stack in form of an array.IntrospectionCacheDataicacheGet(java.lang.Object key)returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the keyvoidicachePut(java.lang.Object key, IntrospectionCacheData o)places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified keyjava.lang.ObjectlocalPut(java.lang.String key, java.lang.Object value)Allows callers to explicitly put objects in the local context.voidpopCurrentMacroName()remove the current macro name from stackvoidpopCurrentTemplateName()remove the current template name from stackvoidpushCurrentMacroName(java.lang.String s)set the current macro name on top of stackvoidpushCurrentTemplateName(java.lang.String s)set the current template name on top of stackjava.lang.Objectput(java.lang.String key, java.lang.Object value)Put method also stores values in parent contextjava.lang.Objectremove(java.lang.Object key)Removes the value associated with the specified key from the context.voidsetCurrentResource(Resource r)voidsetMacroLibraries(java.util.List macroLibraries)Set the macro library list for the current template.
-
-
-
Field Detail
-
innerContext
protected InternalContextAdapter innerContext
the parent context
-
-
Constructor Detail
-
ChainedInternalContextAdapter
public ChainedInternalContextAdapter(InternalContextAdapter inner)
CTOR, wraps an ICA- Parameters:
inner- context
-
-
Method Detail
-
getInternalUserContext
public Context getInternalUserContext()
Return the inner / user context.- Specified by:
getInternalUserContextin interfaceInternalWrapperContext- Returns:
- The inner / user context.
-
getBaseContext
public InternalContextAdapter getBaseContext()
Description copied from interface:InternalWrapperContextReturns the base full context impl.- Specified by:
getBaseContextin interfaceInternalWrapperContext- Returns:
- The base full context impl.
- See Also:
InternalWrapperContext.getBaseContext()
-
get
public java.lang.Object get(java.lang.String key)
Retrieves from parent context.
-
put
public java.lang.Object put(java.lang.String key, java.lang.Object value)Put method also stores values in parent context
-
containsKey
public boolean containsKey(java.lang.Object key)
Description copied from interface:ContextIndicates whether the specified key is in the context.- Specified by:
containsKeyin interfaceContext- Parameters:
key- The key to look for.- Returns:
- Whether the key is in the context.
- See Also:
Context.containsKey(java.lang.Object)
-
getKeys
public java.lang.Object[] getKeys()
Description copied from interface:ContextGet all the keys for the values in the context.- Specified by:
getKeysin interfaceContext- Returns:
- All the keys for the values in the context.
- See Also:
Context.getKeys()
-
remove
public java.lang.Object remove(java.lang.Object key)
Description copied from interface:ContextRemoves the value associated with the specified key from the context.- Specified by:
removein interfaceContext- Parameters:
key- The name of the value to remove.- Returns:
- The value that the key was mapped to, or
nullif unmapped. - See Also:
Context.remove(java.lang.Object)
-
pushCurrentTemplateName
public void pushCurrentTemplateName(java.lang.String s)
Description copied from interface:InternalHousekeepingContextset the current template name on top of stack- Specified by:
pushCurrentTemplateNamein interfaceInternalHousekeepingContext- Parameters:
s- current template name- See Also:
InternalHousekeepingContext.pushCurrentTemplateName(java.lang.String)
-
popCurrentTemplateName
public void popCurrentTemplateName()
Description copied from interface:InternalHousekeepingContextremove the current template name from stack- Specified by:
popCurrentTemplateNamein interfaceInternalHousekeepingContext- See Also:
InternalHousekeepingContext.popCurrentTemplateName()
-
getCurrentTemplateName
public java.lang.String getCurrentTemplateName()
Description copied from interface:InternalHousekeepingContextget the current template name- Specified by:
getCurrentTemplateNamein interfaceInternalHousekeepingContext- Returns:
- String current template name
- See Also:
InternalHousekeepingContext.getCurrentTemplateName()
-
getTemplateNameStack
public java.lang.Object[] getTemplateNameStack()
Description copied from interface:InternalHousekeepingContextReturns the template name stack in form of an array.- Specified by:
getTemplateNameStackin interfaceInternalHousekeepingContext- Returns:
- Object[] with the template name stack contents.
- See Also:
InternalHousekeepingContext.getTemplateNameStack()
-
pushCurrentMacroName
public void pushCurrentMacroName(java.lang.String s)
Description copied from interface:InternalHousekeepingContextset the current macro name on top of stack- Specified by:
pushCurrentMacroNamein interfaceInternalHousekeepingContext- Parameters:
s- current macro name- See Also:
InternalHousekeepingContext.pushCurrentMacroName(java.lang.String)
-
popCurrentMacroName
public void popCurrentMacroName()
Description copied from interface:InternalHousekeepingContextremove the current macro name from stack- Specified by:
popCurrentMacroNamein interfaceInternalHousekeepingContext- See Also:
InternalHousekeepingContext.popCurrentMacroName()
-
getCurrentMacroName
public java.lang.String getCurrentMacroName()
Description copied from interface:InternalHousekeepingContextget the current macro name- Specified by:
getCurrentMacroNamein interfaceInternalHousekeepingContext- Returns:
- String current macro name
- See Also:
InternalHousekeepingContext.getCurrentMacroName()
-
getCurrentMacroCallDepth
public int getCurrentMacroCallDepth()
Description copied from interface:InternalHousekeepingContextget the current macro call depth- Specified by:
getCurrentMacroCallDepthin interfaceInternalHousekeepingContext- Returns:
- int current macro call depth
- See Also:
InternalHousekeepingContext.getCurrentMacroCallDepth()
-
getMacroNameStack
public java.lang.Object[] getMacroNameStack()
Description copied from interface:InternalHousekeepingContextReturns the macro name stack in form of an array.- Specified by:
getMacroNameStackin interfaceInternalHousekeepingContext- Returns:
- Object[] with the macro name stack contents.
- See Also:
InternalHousekeepingContext.getMacroNameStack()
-
icacheGet
public IntrospectionCacheData icacheGet(java.lang.Object key)
Description copied from interface:InternalHousekeepingContextreturns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key- Specified by:
icacheGetin interfaceInternalHousekeepingContext- Parameters:
key- key to find in cache- Returns:
- cache object
- See Also:
InternalHousekeepingContext.icacheGet(java.lang.Object)
-
localPut
public java.lang.Object localPut(java.lang.String key, java.lang.Object value)Description copied from interface:InternalWrapperContextAllows 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:
localPutin interfaceInternalWrapperContext- Parameters:
key- name of item to set.value- object to set to key.- Returns:
- old stored object
- See Also:
InternalWrapperContext.localPut(java.lang.String,java.lang.Object)
-
icachePut
public void icachePut(java.lang.Object key, IntrospectionCacheData o)Description copied from interface:InternalHousekeepingContextplaces an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key- Specified by:
icachePutin interfaceInternalHousekeepingContext- Parameters:
key- keyo- IntrospectionCacheData object to place in cache- See Also:
InternalHousekeepingContext.icachePut(java.lang.Object, org.apache.velocity.util.introspection.IntrospectionCacheData)
-
setMacroLibraries
public void setMacroLibraries(java.util.List macroLibraries)
Description copied from interface:InternalHousekeepingContextSet the macro library list for the current template.- Specified by:
setMacroLibrariesin interfaceInternalHousekeepingContext- Parameters:
macroLibraries- list of macro libraries to set- See Also:
InternalHousekeepingContext.setMacroLibraries(List)
-
getMacroLibraries
public java.util.List getMacroLibraries()
Description copied from interface:InternalHousekeepingContextGet the macro library list for the current template.- Specified by:
getMacroLibrariesin interfaceInternalHousekeepingContext- Returns:
- List of macro library names
- See Also:
InternalHousekeepingContext.getMacroLibraries()
-
attachEventCartridge
public EventCartridge attachEventCartridge(EventCartridge ec)
- Specified by:
attachEventCartridgein interfaceInternalEventContext- Returns:
- The old EventCartridge.
- See Also:
InternalEventContext.attachEventCartridge(org.apache.velocity.app.event.EventCartridge)
-
getEventCartridge
public EventCartridge getEventCartridge()
- Specified by:
getEventCartridgein interfaceInternalEventContext- Returns:
- The current EventCartridge.
- See Also:
InternalEventContext.getEventCartridge()
-
setCurrentResource
public void setCurrentResource(Resource r)
- Specified by:
setCurrentResourcein interfaceInternalHousekeepingContext- See Also:
InternalHousekeepingContext.setCurrentResource(org.apache.velocity.runtime.resource.Resource)
-
getCurrentResource
public Resource getCurrentResource()
Description copied from interface:InternalHousekeepingContexttemporary fix to enable #include() to figure out current encoding.- Specified by:
getCurrentResourcein interfaceInternalHousekeepingContext- Returns:
- The current resource.
- See Also:
InternalHousekeepingContext.getCurrentResource()
-
-