Package org.apache.velocity.exception

Examples of org.apache.velocity.exception.ParseErrorException


            String property = param.substring(0, idx);

            String value = param.substring(idx + 1);
            propertyMap.put(property, value);
        } else {
            throw new ParseErrorException("#" + this.getName() + " arguments must include an assignment operator!  For example #tag( Component \"template=mytemplate\" ).  #tag( TextField \"mytemplate\" ) is illegal!");
        }
    }
View Full Code Here


        this.servletContext = servletContext;

        isParseError = error instanceof ParseErrorException;

        if (error instanceof ParseErrorException) {
            ParseErrorException pee = (ParseErrorException) error;
            if (pee.getTemplateName().charAt(0) == '/') {
                sourceName = pee.getTemplateName();
            } else {
                sourceName =  '/' + pee.getTemplateName();
            }
            lineNumber = pee.getLineNumber();
            columnNumber = pee.getColumnNumber();

            InputStream is =
                servletContext.getResourceAsStream(sourceName);

            sourceReader = new LineNumberReader(new InputStreamReader(is));
View Full Code Here

        {
            nodeTree = parse(reader, logTag);
        }
        catch (ParseException pex)
        {
            throw new ParseErrorException(pex, null);
        }
        catch (TemplateInitException pex)
        {
            throw new ParseErrorException(pex, null);
        }

        if (nodeTree == null)
        {
            return false;
View Full Code Here

            {
                nodeTree.init(ica, this);
            }
            catch (TemplateInitException pex)
            {
                throw new ParseErrorException(pex, null);
            }
            /**
             * pass through application level runtime exceptions
             */
            catch(RuntimeException e)
View Full Code Here

            throws IOException, ResourceNotFoundException, ParseErrorException,
            MethodInvocationException {

        String column = getChildAsString(context, node, 0);
        if (column == null) {
            throw new ParseErrorException("Column name expected at line "
                    + node.getLine()
                    + ", column "
                    + node.getColumn());
        }
View Full Code Here

        }
        catch (ParseException pex)
        {
            // use the line/column from the template
            Info info = new Info( templateName, node.getLine(), node.getColumn() );
            throw  new ParseErrorException( pex.getMessage(), info );
        }
        catch (TemplateInitException pex)
        {
            Info info = new Info( templateName, node.getLine(), node.getColumn() );
            throw  new ParseErrorException( pex.getMessage(), info );
        }

        /*
         * now we want to init and render.  Chain the context
         * to prevent any changes to the current context.
         */

        if (nodeTree != null)
        {
            InternalContextAdapter ica = new EvaluateContext(context, rsvc);

            ica.pushCurrentTemplateName( templateName );

            try
            {
                try
                {
                    nodeTree.init( ica, rsvc );
                }
                catch (TemplateInitException pex)
                {
                    Info info = new Info( templateName, node.getLine(), node.getColumn() );
                    throw  new ParseErrorException( pex.getMessage(), info );
                }

                try
                {
                    /*
                     *  now render, and let any exceptions fly
                     */
                    nodeTree.render( ica, writer );
                }
                catch (ParseErrorException pex)
                {
                    // convert any parsing errors to the correct line/col
                    Info info = new Info( templateName, node.getLine(), node.getColumn() );
                    throw  new ParseErrorException( pex.getMessage(), info );
                }
            }
            finally
            {
                ica.popCurrentTemplateName();
View Full Code Here

                vmProxy.init(rsvc, context, node);
            }
            catch (TemplateInitException die)
            {
                Info info = new Info(sourceTemplate, node.getLine(), node.getColumn());
                throw new ParseErrorException(die.getMessage() + " at "
                    + Log.formatFileString(info), info);
            }

            try
            {
                return vmProxy.render(context, writer, node);
            }
            catch (RuntimeException e)
            {
                /**
                 * We catch, the exception here so that we can record in
                 * the logs the template and line number of the macro call
                 * which generate the exception.  This information is
                 * especially important for multiple macro call levels.
                 * this is also true for the following catch blocks.
                 */
                rsvc.getLog().error("Exception in macro #" + macroName + " at " +
                  Log.formatFileString(sourceTemplate, getLine(), getColumn()));
                throw e;
            }
            catch (IOException e)
            {
                rsvc.getLog().error("Exception in macro #" + macroName + " at " +
                  Log.formatFileString(sourceTemplate, getLine(), getColumn()));
                throw e;
            }
        }
        else if (strictRef)
        {
            Info info = new Info(sourceTemplate, node.getLine(), node.getColumn());
            throw new ParseErrorException("Macro '#" + macroName + "' is not defined at "
                + Log.formatFileString(info), info);
        }
       
        /**
         * If we cannot find an implementation write the literal text
View Full Code Here

        {
            nodeTree = parse(reader, logTag);
        }
        catch (ParseException pex)
        {
            throw new ParseErrorException(pex);
        }
        catch (TemplateInitException pex)
        {
            throw new ParseErrorException(pex);
        }

        if (nodeTree == null)
        {
            return false;
View Full Code Here

            {
                nodeTree.init(ica, this);
            }
            catch (TemplateInitException pex)
            {
                throw new ParseErrorException(pex);
            }
            /**
             * pass through application level runtime exceptions
             */
            catch(RuntimeException e)
View Full Code Here

        }
        catch( UnsupportedEncodingException  uce )
        {
            String msg = "Unsupported input encoding : " + encoding
                + " for template " + logTag;
            throw new ParseErrorException( msg );
        }

        return evaluate( context, writer, logTag, br );
    }
View Full Code Here

TOP

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

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.