Package org.apache.velocity.context
Class InternalContextAdapterImpl
java.lang.Object
org.apache.velocity.context.InternalContextAdapterImpl
- All Implemented Interfaces:
Context,InternalContextAdapter,InternalEventContext,InternalHousekeepingContext,InternalWrapperContext
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: InternalContextAdapterImpl.java 731266 2009-01-04 15:11:20Z byron $
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Contextthe user data Context that we are wrapping(package private) InternalHousekeepingContextthe ICB we are wrapping.(package private) InternalEventContextThe InternalEventContext that we are wrapping. -
Constructor Summary
ConstructorsConstructorDescriptionCTOR takes a Context and wraps it, delegating all 'data' calls to it. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(Object key) Indicates whether the specified key is in the context.Gets the value corresponding to the provided key from the context.Returns the base context that we are wrapping.intget the current macro call depthget the current macro nametemporary fix to enable #include() to figure out current encoding.get the current template namereturns the user data context that we are wrappingObject[]getKeys()Get all the keys for the values in the context.Get the macro library list for the current template.Object[]Returns the macro name stack in form of an array.Object[]Returns the template name stack in form of an array.returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the keyvoidicachePut(Object key, IntrospectionCacheData o) places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified keyAllows callers to explicitly put objects in the local context.voidremove the current macro name from stackvoidremove the current template name from stackvoidset the current macro name on top of stackvoidset the current template name on top of stackAdds a name/value pair to the context.Removes the value associated with the specified key from the context.voidvoidsetMacroLibraries(List macroLibraries) Set the macro library list for the current template.
-
Field Details
-
context
Context contextthe user data Context that we are wrapping -
icb
the ICB we are wrapping. We may need to make one if the user data context implementation doesn't support one. The default AbstractContext-derived VelocityContext does, and it's recommended that people derive new contexts from AbstractContext rather than piecing things together -
iec
The InternalEventContext that we are wrapping. If the context passed to us doesn't support it, no biggie. We don't make it for them - since its a user context thing, nothing gained by making one for them now
-
-
Constructor Details
-
InternalContextAdapterImpl
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 Details
-
pushCurrentTemplateName
Description copied from interface:InternalHousekeepingContextset the current template name on top of stack- Specified by:
pushCurrentTemplateNamein interfaceInternalHousekeepingContext- Parameters:
s- current template name- See Also:
-
popCurrentTemplateName
public void popCurrentTemplateName()Description copied from interface:InternalHousekeepingContextremove the current template name from stack- Specified by:
popCurrentTemplateNamein interfaceInternalHousekeepingContext- See Also:
-
getCurrentTemplateName
Description copied from interface:InternalHousekeepingContextget the current template name- Specified by:
getCurrentTemplateNamein interfaceInternalHousekeepingContext- Returns:
- String current template name
- See Also:
-
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:
-
pushCurrentMacroName
Description copied from interface:InternalHousekeepingContextset the current macro name on top of stack- Specified by:
pushCurrentMacroNamein interfaceInternalHousekeepingContext- Parameters:
s- current macro name- Since:
- 1.6
- See Also:
-
popCurrentMacroName
public void popCurrentMacroName()Description copied from interface:InternalHousekeepingContextremove the current macro name from stack- Specified by:
popCurrentMacroNamein interfaceInternalHousekeepingContext- Since:
- 1.6
- See Also:
-
getCurrentMacroName
Description copied from interface:InternalHousekeepingContextget the current macro name- Specified by:
getCurrentMacroNamein interfaceInternalHousekeepingContext- Returns:
- String current macro name
- Since:
- 1.6
- See Also:
-
getCurrentMacroCallDepth
public int getCurrentMacroCallDepth()Description copied from interface:InternalHousekeepingContextget the current macro call depth- Specified by:
getCurrentMacroCallDepthin interfaceInternalHousekeepingContext- Returns:
- int current macro call depth
- Since:
- 1.6
- See Also:
-
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.
- Since:
- 1.6
- See Also:
-
icacheGet
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:
-
icachePut
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:
-
setCurrentResource
- Specified by:
setCurrentResourcein interfaceInternalHousekeepingContext- See Also:
-
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:
-
setMacroLibraries
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- Since:
- 1.6
- See Also:
-
getMacroLibraries
Description copied from interface:InternalHousekeepingContextGet the macro library list for the current template.- Specified by:
getMacroLibrariesin interfaceInternalHousekeepingContext- Returns:
- List of macro library names
- Since:
- 1.6
- See Also:
-
put
Description copied from interface:ContextAdds a name/value pair to the context. -
localPut
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
- Since:
- 1.5
- See Also:
-
get
Description copied from interface:ContextGets the value corresponding to the provided key from the context. -
containsKey
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:
-
getKeys
Description copied from interface:ContextGet all the keys for the values in the context. -
remove
Description copied from interface:ContextRemoves the value associated with the specified key from the context. -
getInternalUserContext
returns the user data context that we are wrapping- Specified by:
getInternalUserContextin interfaceInternalWrapperContext- Returns:
- The internal user data context.
-
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:
getBaseContextin interfaceInternalWrapperContext- Returns:
- The base context.
-
attachEventCartridge
- Specified by:
attachEventCartridgein interfaceInternalEventContext- Returns:
- The old EventCartridge.
- See Also:
-
getEventCartridge
- Specified by:
getEventCartridgein interfaceInternalEventContext- Returns:
- The current EventCartridge.
- See Also:
-