Package org.apache.velocity.context
Class InternalContextAdapterImpl
- java.lang.Object
-
- org.apache.velocity.context.InternalContextAdapterImpl
-
- All Implemented Interfaces:
Context
,InternalContextAdapter
,InternalEventContext
,InternalWrapperContext
public final class InternalContextAdapterImpl extends java.lang.Object implements InternalContextAdapter
This adapter class is the container for all context types for internal use. The AST now uses this class rather than the app-level Context interface to allow flexibility in the future. Currently, we have two context interfaces which must be supported :- Context : used for application/template data access
- InternalHousekeepingContext : used for internal housekeeping and caching
- InternalWrapperContext : used for getting root cache context and other such.
- InternalEventContext : for event handling.
- Version:
- $Id$
- Author:
- Geir Magnusson Jr.
-
-
Constructor Summary
Constructors Constructor Description InternalContextAdapterImpl(Context c)
CTOR takes a Context and wraps it, delegating all 'data' calls to it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventCartridge
attachEventCartridge(EventCartridge ec)
boolean
containsKey(java.lang.String key)
Indicates whether the specified key is in the context.java.lang.Object
get(java.lang.String key)
Gets the value corresponding to the provided key from the context.InternalContextAdapter
getBaseContext()
Returns the base context that we are wrapping.int
getCurrentMacroCallDepth()
java.lang.String
getCurrentMacroName()
Resource
getCurrentResource()
java.lang.String
getCurrentTemplateName()
EventCartridge
getEventCartridge()
Context
getInternalUserContext()
returns the user data context that we are wrappingjava.lang.String[]
getKeys()
Get all the keys for the values in the context.java.util.List<Template>
getMacroLibraries()
java.lang.String[]
getMacroNameStack()
java.lang.String[]
getTemplateNameStack()
IntrospectionCacheData
icacheGet(java.lang.Object key)
void
icachePut(java.lang.Object key, IntrospectionCacheData o)
void
popCurrentMacroName()
void
popCurrentTemplateName()
void
pushCurrentMacroName(java.lang.String s)
void
pushCurrentTemplateName(java.lang.String s)
java.lang.Object
put(java.lang.String key, java.lang.Object value)
Adds a name/value pair to the context.java.lang.Object
remove(java.lang.String key)
Removes the value associated with the specified key from the context.void
setCurrentResource(Resource r)
void
setMacroLibraries(java.util.List<Template> macroLibraries)
-
-
-
Constructor Detail
-
InternalContextAdapterImpl
public InternalContextAdapterImpl(Context c)
CTOR takes a Context and wraps it, delegating all 'data' calls to it. For support of internal contexts, it will create an InternalContextBase if need be.- Parameters:
c
-
-
-
Method Detail
-
pushCurrentTemplateName
public void pushCurrentTemplateName(java.lang.String s)
- See Also:
InternalHousekeepingContext.pushCurrentTemplateName(java.lang.String)
-
popCurrentTemplateName
public void popCurrentTemplateName()
- See Also:
InternalHousekeepingContext.popCurrentTemplateName()
-
getCurrentTemplateName
public java.lang.String getCurrentTemplateName()
- See Also:
InternalHousekeepingContext.getCurrentTemplateName()
-
getTemplateNameStack
public java.lang.String[] getTemplateNameStack()
- See Also:
InternalHousekeepingContext.getTemplateNameStack()
-
pushCurrentMacroName
public void pushCurrentMacroName(java.lang.String s)
- Since:
- 1.6
- See Also:
InternalHousekeepingContext.pushCurrentMacroName(java.lang.String)
-
popCurrentMacroName
public void popCurrentMacroName()
- Since:
- 1.6
- See Also:
InternalHousekeepingContext.popCurrentMacroName()
-
getCurrentMacroName
public java.lang.String getCurrentMacroName()
- Since:
- 1.6
- See Also:
InternalHousekeepingContext.getCurrentMacroName()
-
getCurrentMacroCallDepth
public int getCurrentMacroCallDepth()
- Since:
- 1.6
- See Also:
InternalHousekeepingContext.getCurrentMacroCallDepth()
-
getMacroNameStack
public java.lang.String[] getMacroNameStack()
- Since:
- 1.6
- See Also:
InternalHousekeepingContext.getMacroNameStack()
-
icacheGet
public IntrospectionCacheData icacheGet(java.lang.Object key)
- See Also:
InternalHousekeepingContext.icacheGet(java.lang.Object)
-
icachePut
public void icachePut(java.lang.Object key, IntrospectionCacheData o)
- See Also:
InternalHousekeepingContext.icachePut(java.lang.Object, org.apache.velocity.util.introspection.IntrospectionCacheData)
-
setCurrentResource
public void setCurrentResource(Resource r)
- See Also:
InternalHousekeepingContext.setCurrentResource(org.apache.velocity.runtime.resource.Resource)
-
getCurrentResource
public Resource getCurrentResource()
- See Also:
InternalHousekeepingContext.getCurrentResource()
-
setMacroLibraries
public void setMacroLibraries(java.util.List<Template> macroLibraries)
- Since:
- 1.6
- See Also:
InternalHousekeepingContext.setMacroLibraries(List)
-
getMacroLibraries
public java.util.List<Template> getMacroLibraries()
- Since:
- 1.6
- See Also:
InternalHousekeepingContext.getMacroLibraries()
-
put
public java.lang.Object put(java.lang.String key, java.lang.Object value)
Description copied from interface:Context
Adds a name/value pair to the context.- Specified by:
put
in interfaceContext
- Specified by:
put
in interfaceInternalWrapperContext
- 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, java.lang.Object)
-
get
public java.lang.Object get(java.lang.String key)
Description copied from interface:Context
Gets the value corresponding to the provided key from the context.- Specified by:
get
in interfaceContext
- Specified by:
get
in interfaceInternalWrapperContext
- Parameters:
key
- The name of the desired value.- Returns:
- The value corresponding to the provided key.
- See Also:
Context.get(java.lang.String)
-
containsKey
public boolean containsKey(java.lang.String key)
Description copied from interface:Context
Indicates whether the specified key is in the context.- Specified by:
containsKey
in interfaceContext
- Specified by:
containsKey
in interfaceInternalWrapperContext
- Parameters:
key
- The key to look for.- Returns:
- Whether the key is in the context.
- See Also:
Context.containsKey(java.lang.String)
-
getKeys
public java.lang.String[] getKeys()
Description copied from interface:Context
Get all the keys for the values in the context.- Specified by:
getKeys
in interfaceContext
- Returns:
- All the keys for the values in the context.
- See Also:
Context.getKeys()
-
remove
public java.lang.Object remove(java.lang.String key)
Description copied from interface:Context
Removes the value associated with the specified key from the context.- Specified by:
remove
in interfaceContext
- 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.String)
-
getInternalUserContext
public Context getInternalUserContext()
returns the user data context that we are wrapping- Specified by:
getInternalUserContext
in interfaceInternalWrapperContext
- Returns:
- The internal user data context.
-
getBaseContext
public InternalContextAdapter getBaseContext()
Returns the base context that we are wrapping. Here, its this, but for other thing like VM related context contortions, it can be something else- Specified by:
getBaseContext
in interfaceInternalWrapperContext
- Returns:
- The base context.
-
attachEventCartridge
public EventCartridge attachEventCartridge(EventCartridge ec)
- Specified by:
attachEventCartridge
in interfaceInternalEventContext
- Returns:
- The old EventCartridge.
- See Also:
InternalEventContext.attachEventCartridge(org.apache.velocity.app.event.EventCartridge)
-
getEventCartridge
public EventCartridge getEventCartridge()
- Specified by:
getEventCartridge
in interfaceInternalEventContext
- Returns:
- The current EventCartridge.
- See Also:
InternalEventContext.getEventCartridge()
-
-