Class VelocimacroProxy

    • Constructor Detail

      • VelocimacroProxy

        public VelocimacroProxy()
    • Method Detail

      • getName

        public String getName()
        Return name of this Velocimacro.
        Specified by:
        getName in class Directive
        Returns:
        The name of this Velocimacro.
      • getType

        public int getType()
        Velocimacros are always LINE type directives.
        Specified by:
        getType in class Directive
        Returns:
        The type of this directive.
      • setName

        public void setName​(String name)
        sets the directive name of this VM
        Parameters:
        name -
      • setMacroArgs

        public void setMacroArgs​(List<Macro.MacroArg> args)
        sets the array of arguments specified in the macro definition
        Parameters:
        args - Array of macro arguments, containing the #macro() arguments and default values. the 0th is the name.
      • getMacroArgs

        public List<Macro.MacroArg> getMacroArgs()
        Return the list of macro arguments associated with this macro
        Returns:
        macro arguments
      • setNodeTree

        public void setNodeTree​(SimpleNode tree)
        Parameters:
        tree -
      • getNumArgs

        public int getNumArgs()
        returns the number of ars needed for this VM
        Returns:
        The number of ars needed for this VM
      • init

        public void init​(RuntimeServices rs)
        Initialize members of VelocimacroProxy. called from MacroEntry
        Parameters:
        rs - runtime services
      • render

        public boolean render​(InternalContextAdapter context,
                              Writer writer,
                              Node node,
                              Renderable body)
                       throws IOException
        Renders the macro using the context.
        Parameters:
        context - Current rendering context
        writer - Writer for output
        node - AST that calls the macro
        body - the macro body
        Returns:
        true if the directive rendered successfully.
        Throws:
        IOException
      • checkArgumentCount

        protected void checkArgumentCount​(Node node,
                                          int callArgNum)
        Check whether the number of arguments given matches the number defined.
        Parameters:
        node -
        callArgNum -
      • checkDepth

        protected void checkDepth​(InternalContextAdapter context)
        check that we aren't already at the max call depth and throws a MacroOverflowException if we are there.
        Parameters:
        context -
      • handleArgValues

        protected Object[] handleArgValues​(InternalContextAdapter context,
                                           Node node,
                                           int callArgNum)
        Gets the macro argument values and puts them in the context under the argument names. Store and return an array of old and new values paired for each argument name, for later cleanup. Also, put literal representations of arguments which evaluate to null in the context.
        Parameters:
        context -
        node -
        callArgNum -
        Returns:
        macro arguments values