Class Macro

  • All Implemented Interfaces:
    java.lang.Cloneable, DirectiveConstants

    public class Macro
    extends Directive
    Macro implements the macro definition directive of VTL. example: #macro( isnull $i ) #if( $i ) $i #end #end This object is used at parse time to mainly process and register the macro. It is used inline in the parser when processing a directive.
    Version:
    $Id$
    Author:
    Geir Magnusson Jr., Henning P. Schmiedehausen
    • Constructor Detail

      • Macro

        public Macro()
    • Method Detail

      • getName

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

        public int getType()
        Return type of this directive.
        Specified by:
        getType in class Directive
        Returns:
        The type of this directive.
      • isScopeProvided

        public boolean isScopeProvided()
        Since this class does no processing of content, there is never a need for an internal scope.
        Overrides:
        isScopeProvided in class Directive
        Returns:
        true if there will be a scope control injected into the context when rendering this directive.
      • render

        public boolean render​(InternalContextAdapter context,
                              java.io.Writer writer,
                              Node node)
                       throws java.io.IOException
        render() doesn't do anything in the final output rendering. There is no output from a #macro() directive.
        Specified by:
        render in class Directive
        Parameters:
        context -
        writer -
        node -
        Returns:
        True if the directive rendered successfully.
        Throws:
        java.io.IOException
      • checkArgs

        public void checkArgs​(java.util.ArrayList<java.lang.Integer> argtypes,
                              Token t,
                              java.lang.String templateName)
                       throws ParseException
        Check the argument types of a macro call, called by the parser to do validation
        Overrides:
        checkArgs in class Directive
        Parameters:
        argtypes - type, Array of argument types of each argument to the directive for example StandardParserTreeConstants.JJTWORD
        t - token of directive
        templateName - the name of the template this directive is referenced in.
        Throws:
        ParseException
      • macroToString

        public static java.lang.StringBuilder macroToString​(java.lang.StringBuilder buf,
                                                            java.util.List<Macro.MacroArg> macroArgs,
                                                            RuntimeServices rsvc)
        For debugging purposes. Formats the arguments from argArray and appends them to buf.
        Parameters:
        buf - A StringBuilder. If null, a new StringBuilder is allocated.
        macroArgs - Array of macro arguments, containing the #macro() arguments and default values. the 0th is the name.
        Returns:
        A StringBuilder containing the formatted arguments. If a StringBuilder has passed in as buf, this method returns it.
        Since:
        1.5