Package org.apache.velocity.runtime.parser.node

Examples of org.apache.velocity.runtime.parser.node.SimpleNode


        if (logTag == null)
        {
            throw new NullPointerException("logTag (i.e. template name) cannot be null, you must provide an identifier for the content being evaluated");
        }

        SimpleNode nodeTree = null;
        try
        {
            nodeTree = parse(reader, logTag);
        }
        catch (ParseException pex)
View Full Code Here


     */
    public SimpleNode parse( Reader reader, String templateName, boolean dumpNamespace )
        throws ParseException
    {

        SimpleNode ast = null;
        Parser parser = (Parser) parserPool.get();
        boolean madeNew = false;

        if (parser == null)
        {
View Full Code Here

  static String getOverrideVariableName(String name) {
    return BLOCK + name;
  }
 
  static String getRequiredArgument(InternalContextAdapter context,Node node,int argumentIndex,String directive) throws ParseErrorException {
    SimpleNode sn_value = (SimpleNode)node.jjtGetChild(argumentIndex);
        if ( sn_value == null){
          throw new ParseErrorException("required argument is null with directive:#"+directive+"(),argumentIndex="+argumentIndex);
        }
       
    String value = (String)sn_value.value(context);
    if ( value == null){
      throw new ParseErrorException("required argument is null with directive:#"+directive+"(),argumentIndex="+argumentIndex);
        }
    return value;
  }
View Full Code Here

     */
    public SimpleNode parse( Reader reader, String templateName, boolean dumpNamespace )
        throws ParseException
    {

        SimpleNode ast = null;
        Parser parser = (Parser) parserPool.get();
        boolean madeNew = false;

        if (parser == null)
        {
View Full Code Here

    public boolean evaluate( Context context, Writer writer,
                                    String logTag, Reader reader )
        throws ParseErrorException, MethodInvocationException,
          ResourceNotFoundException,IOException
    {
        SimpleNode nodeTree = null;
       
        try
        {
            nodeTree = ri.parse( reader, logTag );       
        }
        catch ( ParseException pex )
        {
            throw  new ParseErrorException( pex.getMessage() );
        }               
    
        /*
         * now we want to init and render
         */

        if (nodeTree != null)
        {
            InternalContextAdapterImpl ica =
                new InternalContextAdapterImpl( context );
           
            ica.pushCurrentTemplateName( logTag );
           
            try
            {
                try
                {
                    nodeTree.init( ica, ri );
                }
                catch( Exception e )
                {
                    ri.error("Velocity.evaluate() : init exception for tag = "
                                  + logTag + " : " + e );
                }
               
                /*
                 *  now render, and let any exceptions fly
                 */

                nodeTree.render( ica, writer );
            }
            finally
            {
                ica.popCurrentTemplateName();
            }
View Full Code Here

               
        /*
         *  this is really the only thing we can do here as everything
         *  else is context sensitive
         */
        SimpleNode sn = (SimpleNode) node.jjtGetChild(0);

    DEBUG.P("sn="+sn);
        if (sn instanceof ASTReference)
        {
            elementKey = ((ASTReference) sn).getRootString();
        }
        else
        {
            /*
             * the default, error-prone way which we'll remove
             *  TODO : remove if all goes well
             */
            elementKey = sn.getFirstToken().image.substring(1);
        }

    DEBUG.P("elementKey="+elementKey);
        /*
         * make an uberinfo - saves new's later on
View Full Code Here

             * get the references
             */

            for (int i=0; i < num; i++)
            {
                SimpleNode child = (SimpleNode) node.jjtGetChild(i);

                /*
                 * if a block, just execute
                 */

                if (child.getType() == ParserTreeConstants.JJTBLOCK)
                {
                    child.render(context, writer);
                    break;
                }
                else
                {
                    /* save the values - for now, just w/ ref to test */

                    if (child.getType() == ParserTreeConstants.JJTREFERENCE)
                    {
                        data.put(child, child.execute(null, context));
                    }
                    else
                    {
                        System.out.println("unhandled type");
                    }
View Full Code Here

        if (logTag == null)
        {
            throw new NullPointerException("logTag (i.e. template name) cannot be null, you must provide an identifier for the content being evaluated");
        }

        SimpleNode nodeTree = null;
        try
        {
            nodeTree = parse(reader, logTag);
        }
        catch (ParseException pex)
View Full Code Here

     *  returns a list of references in a template in the
     *  order that they are encountered
     */
    public static List referenceList( Template template )
    {
        SimpleNode sn = (SimpleNode) template.getData();

        ReferenceListVisitor rlv = new ReferenceListVisitor();

        sn.jjtAccept( rlv, null );

        return rlv.getList();
    }
View Full Code Here

        /*
         *  get all the references in our arg list
         */
        for (int i=0; i < numchildren-1; i++)
        {
            SimpleNode sn = (SimpleNode) node.jjtGetChild(i);

            if (sn instanceof ASTReference )
            {
                al.add(sn);
            }
View Full Code Here

TOP

Related Classes of org.apache.velocity.runtime.parser.node.SimpleNode

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.