Class InternalContextAdapterImpl

  • All Implemented Interfaces:
    Context, InternalContextAdapter, InternalEventContext, InternalWrapperContext

    public final class InternalContextAdapterImpl
    extends 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.
    This class implements the two interfaces to ensure that all methods are supported. When adding to the interfaces, or adding more context functionality, the interface is the primary definition, so alter that first and then all classes as necessary. As of this writing, this would be the only class affected by changes to InternalContext This class ensures that an InternalContextBase is available for internal use. If an application constructs their own Context-implementing object w/o subclassing AbstractContext, it may be that support for InternalContext is not available. Therefore, InternalContextAdapter will create an InternalContextBase if necessary for this support. Note that if this is necessary, internal information such as node-cache data will be lost from use to use of the context. This may or may not be important, depending upon application.
    Version:
    $Id$
    Author:
    Geir Magnusson Jr.
    • 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​(String s)
        See Also:
        InternalHousekeepingContext.pushCurrentTemplateName(java.lang.String)
      • popCurrentTemplateName

        public void popCurrentTemplateName()
        See Also:
        InternalHousekeepingContext.popCurrentTemplateName()
      • getCurrentTemplateName

        public String getCurrentTemplateName()
        See Also:
        InternalHousekeepingContext.getCurrentTemplateName()
      • getTemplateNameStack

        public String[] getTemplateNameStack()
        See Also:
        InternalHousekeepingContext.getTemplateNameStack()
      • pushCurrentMacroName

        public void pushCurrentMacroName​(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 String getCurrentMacroName()
        Since:
        1.6
        See Also:
        InternalHousekeepingContext.getCurrentMacroName()
      • getCurrentMacroCallDepth

        public int getCurrentMacroCallDepth()
        Since:
        1.6
        See Also:
        InternalHousekeepingContext.getCurrentMacroCallDepth()
      • getMacroNameStack

        public String[] getMacroNameStack()
        Since:
        1.6
        See Also:
        InternalHousekeepingContext.getMacroNameStack()
      • icachePut

        public void icachePut​(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​(List<Template> macroLibraries)
        Since:
        1.6
        See Also:
        InternalHousekeepingContext.setMacroLibraries(List)
      • getMacroLibraries

        public List<Template> getMacroLibraries()
        Since:
        1.6
        See Also:
        InternalHousekeepingContext.getMacroLibraries()
      • getKeys

        public String[] 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​(String key)
        Description copied from interface: Context
        Removes the value associated with the specified key 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.String)
      • 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 interface InternalWrapperContext
        Returns:
        The base context.