Package org.apache.velocity.exception

Examples of org.apache.velocity.exception.TemplateInitException


        @Override
        public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
            super.init(rs, context, node);

            if (node.jjtGetNumChildren() != 1) {
                throw new TemplateInitException("Invalid args for #" + getName() + ".  Expected 0 args.",
                                                context.getCurrentTemplateName(), node.getColumn(), node.getLine());
            }
        }
View Full Code Here


        @Override
        public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
            super.init(rs, context, node);

            if (node.jjtGetNumChildren() != 2) {
                throw new TemplateInitException("Invalid args for #" + getName()
                        + ".  Expected 1 and only 1 string arg.", context.getCurrentTemplateName(), node.getColumn(),
                        node.getLine());
            }
        }
View Full Code Here

        @Override
        public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
            super.init(rs, context, node);

            if (node.jjtGetNumChildren() != 1) {
                throw new TemplateInitException("Invalid args for #" + getName() + ".  Expected 0 args.",
                        context.getCurrentTemplateName(), node.getColumn(), node.getLine());
            }
        }
View Full Code Here

            if (strictArguments)
            {
                /**
                 * indicate col/line assuming it starts at 0 - this will be corrected one call up
                 */
                throw new TemplateInitException(msg, context.getCurrentTemplateName(), 0, 0);
            }
            else
            {
                rsvc.getLog().debug(msg);
                return;
View Full Code Here

                /**
                 * correct the line/column number if an exception is caught
                 */
                catch (TemplateInitException die)
                {
                    throw new TemplateInitException(die.getMessage(),
                            (ParseException) die.getWrappedThrowable(),
                            die.getTemplateName(),
                            die.getColumnNumber() + getColumn(),
                            die.getLineNumber() + getLine());
                }
View Full Code Here

                nodeTree = rsvc.parse(br, (context != null) ? context
                        .getCurrentTemplateName() : "StringLiteral", false);
            }
            catch (ParseException e)
            {
                throw new TemplateInitException(
                        "Problem parsing String literal.", e,
                        (context != null) ? context.getCurrentTemplateName()
                                : "StringLiteral", getColumn(), getLine());
            }
View Full Code Here

            if (strictArguments)
            {
                /**
                 * indicate col/line assuming it starts at 0 - this will be corrected one call up
                 */
                throw new TemplateInitException(msg, context.getCurrentTemplateName(), 0, 0);
            }
            else
            {
                rsvc.getLog().debug(msg);
                return;
            }
        }

        /* now validate that none of the arguments are plain words, (VELOCITY-614)
         * they should be string literals, references, inline maps, or inline lists */
        for (int n=0; n < i; n++)
        {
            Node child = node.jjtGetChild(n);
            if (child.getType() == ParserTreeConstants.JJTWORD)
            {
                /* indicate col/line assuming it starts at 0
                 * this will be corrected one call up  */
                throw new TemplateInitException("Invalid arg #"
                    + n + " in VM #" + macroName, context.getCurrentTemplateName(), 0, 0);
            }
        }
    }
View Full Code Here

                /**
                 * correct the line/column number if an exception is caught
                 */
                catch (TemplateInitException die)
                {
                    throw new TemplateInitException(die.getMessage(),
                            (ParseException) die.getWrappedThrowable(),
                            die.getTemplateName(),
                            die.getColumnNumber() + getColumn(),
                            die.getLineNumber() + getLine());
                }
View Full Code Here

         */ 
       
        int argCount = node.jjtGetNumChildren();
        if (argCount == 0)
        {
            throw new TemplateInitException(
                    "#" + getName() + "() requires exactly one argument",
                    context.getCurrentTemplateName(),
                    node.getColumn(),
                    node.getLine());           
        }
        if (argCount > 1)
        {
            /*
             * use line/col of second argument
             */
           
            throw new TemplateInitException(
                    "#" + getName() + "() requires exactly one argument",
                    context.getCurrentTemplateName(),
                    node.jjtGetChild(1).getColumn(),
                    node.jjtGetChild(1).getLine());
        }
       
        Node childNode = node.jjtGetChild(0);
        if ( childNode.getType() !=  ParserTreeConstants.JJTSTRINGLITERAL &&
             childNode.getType() !=  ParserTreeConstants.JJTREFERENCE )
        {
           throw new TemplateInitException(
                   "#" + getName() + "()  argument must be a string literal or reference",
                   context.getCurrentTemplateName(),
                   childNode.getColumn(),
                   childNode.getLine());
        }
View Full Code Here

             
                if (strictRef// If strict, throw now
                {
                    /* indicate col/line assuming it starts at 0
                     * this will be corrected one call up  */
                    throw new TemplateInitException(badArgsErrorMsg,
                        context.getCurrentTemplateName(), 0, 0);
                }
            }
        }              
    }
View Full Code Here

TOP

Related Classes of org.apache.velocity.exception.TemplateInitException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.