Class Foreach

    • Field Detail

      • uberInfo

        protected Info uberInfo
        immutable, so create in init
    • Constructor Detail

      • Foreach

        public Foreach()
    • Method Detail

      • getName

        public 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.
      • put

        protected void put​(InternalContextAdapter context,
                           String key,
                           Object value)
        Extension hook to allow subclasses to control whether loop vars are set locally or not. So, those in favor of VELOCITY-285, can make that happen easily by overriding this and having it use context.localPut(k,v). See VELOCITY-630 for more on this.
        Parameters:
        context -
        key -
        value -
      • getIterator

        protected Iterator getIterator​(Object iterable,
                                       Node node)
        Retrieve the contextual iterator.
        Parameters:
        iterable -
        node -
        Returns:
        iterator
      • checkArgs

        public void checkArgs​(ArrayList<Integer> argtypes,
                              Token t,
                              String templateName)
                       throws ParseException
        We do not allow a word token in any other arg position except for the 2nd since we are looking for the pattern #foreach($foo in $bar).
        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