On Thu, 2002-03-14 at 03:23, Christian Trutz wrote:
>
> Hello velocitians,
>
> I experimentize a little with ParserVisitors on AST and I think the following
> patch is usefull:
>
> it allows processing the AST nodes with a visitor, until now:
>
> template.merge( context, writer );
>
> now:
>
> template.merge( context, writer );
> and
> template.merge( context, visitor );
>
> are avaible. I think this is a trivial change, but it is usefull ...
I actually don't like the idea of changing something so fundamental but
I would be curious if you tried any profiling to see if there was any
performance difference between using a visitor and the self-walking
tree.
> Christian
>
>
> Index: Template.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-velocity/src/java/org/apache/velocity/Template.java,v
> retrieving revision 1.35
> diff -r1.35 Template.java
> 66a67
> > import org.apache.velocity.runtime.parser.node.ParserVisitor;
> 261a263
> > * @param parser visitor for rendering template
> 268c270
> < public void merge( Context context, Writer writer)
> ---
> > public void merge( Context context, Writer writer, ParserVisitor
> visitor)
> 296c298,312
> < ( (SimpleNode) data ).render( ica, writer);
> ---
> > if ( visitor == null )
> > {
> > /*
> > * standard template rendering
> > */
> > ( (SimpleNode) data ).render( ica, writer);
> > }
> > else
> > {
> > /*
> > * render template with a visitor
> > */
> > visitor.visit( (SimpleNode) data, data);
> > }
> >
> 318a335,376
> > }
> >
> > /**
> > * The AST node structure is merged with the
> > * context to produce the final output.
> > *
> > * Throws IOException if failure is due to a file related
> > * issue, and Exception otherwise
> > *
> > * @param context Conext with data elements accessed by template
> > * @param writer output writer for rendered template
> > * @throws ResourceNotFoundException if template not found
> > * from any available source.
> > * @throws ParseErrorException if template cannot be parsed due
> > * to syntax (or other) error.
> > * @throws Exception anything else.
> > */
> > public void merge( Context context, Writer writer)
> > throws ResourceNotFoundException, ParseErrorException,
> MethodInvocationException, Exception
> > {
> > merge( context, writer, null);
> > }
> >
> > /**
> > * The AST node structure is merged with the
> > * context to produce the final output.
> > *
> > * Throws IOException if failure is due to a file related
> > * issue, and Exception otherwise
> > *
> > * @param context Conext with data elements accessed by template
> > * @param parser visitor for rendering template
> > * @throws ResourceNotFoundException if template not found
> > * from any available source.
> > * @throws ParseErrorException if template cannot be parsed due
> > * to syntax (or other) error.
> > * @throws Exception anything else.
> > */
> > public void merge( Context context, ParserVisitor visitor)
> > throws ResourceNotFoundException, ParseErrorException,
> MethodInvocationException, Exception
> > {
> > merge( context, null, visitor);
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
jvz.
Jason van Zyl
[EMAIL PROTECTED]
http://tambora.zenplex.org
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>