Class ProxyVMContext

    • Field Detail

      • vmproxyhash

        java.util.Map vmproxyhash
        container for our macro AST node arguments. Size must be power of 2.
      • localcontext

        java.util.Map localcontext
        container for any local or constant macro arguments. Size must be power of 2.
      • localContextScope

        private boolean localContextScope
        support for local context scope feature, where all references are local
    • Constructor Detail

      • ProxyVMContext

        public ProxyVMContext​(InternalContextAdapter inner,
                              RuntimeServices rsvc,
                              boolean localContextScope)
        Parameters:
        inner - Velocity context for processing
        rsvc - RuntimeServices provides logging reference
        localContextScope - if true, all references are set to be local
    • Method Detail

      • addVMProxyArg

        public void addVMProxyArg​(InternalContextAdapter context,
                                  java.lang.String macroArgumentName,
                                  java.lang.String literalMacroArgumentName,
                                  Node argumentValue)
                           throws MethodInvocationException
        Used to put Velocity macro arguments into this context.
        Parameters:
        context - rendering context
        macroArgumentName - name of the macro argument that we received
        literalMacroArgumentName - ".literal.$"+macroArgumentName
        argumentValue - actual value of the macro argument
        Throws:
        MethodInvocationException
      • addVMProxyArg

        public void addVMProxyArg​(InternalContextAdapter context,
                                  java.lang.String macroArgumentName,
                                  java.lang.String literalMacroArgumentName,
                                  Renderable argumentValue)
                           throws MethodInvocationException
        Used to put Velocity macro bodyContext arguments into this context.
        Parameters:
        context - rendering context
        macroArgumentName - name of the macro argument that we received
        literalMacroArgumentName - ".literal.$"+macroArgumentName
        argumentValue - actual value of the macro body
        Throws:
        MethodInvocationException
      • isConstant

        private boolean isConstant​(Node node)
        AST nodes that are considered constants can be directly saved into the context. Dynamic values are stored in another argument hashmap.
        Parameters:
        node - macro argument as AST node
        Returns:
        true if the node is a constant value
      • put

        public java.lang.Object put​(java.lang.String key,
                                    java.lang.Object value)
        Impl of the Context.put() method.
        Specified by:
        put in interface Context
        Overrides:
        put in class ChainedInternalContextAdapter
        Parameters:
        key - name of item to set
        value - object to set to key
        Returns:
        old stored object
      • put

        protected java.lang.Object put​(java.lang.String key,
                                       java.lang.Object value,
                                       boolean forceLocal)
        Internal put method to select between local and global scope.
        Parameters:
        key - name of item to set
        value - object to set to key
        forceLocal - True forces the object into the local scope.
        Returns:
        old stored object
      • get

        public java.lang.Object get​(java.lang.String key)
        Implementation of the Context.get() method. First checks localcontext, then arguments, then global context.
        Specified by:
        get in interface Context
        Overrides:
        get in class ChainedInternalContextAdapter
        Parameters:
        key - name of item to get
        Returns:
        stored object or null
      • remove

        public java.lang.Object remove​(java.lang.Object key)
        Description copied from interface: Context
        Removes the value associated with the specified key from the context.
        Specified by:
        remove in interface Context
        Overrides:
        remove in class ChainedInternalContextAdapter
        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)