org.apache.velocity.runtime.directive
Class VelocimacroProxy

java.lang.Object
  extended by org.apache.velocity.runtime.directive.Directive
      extended by org.apache.velocity.runtime.directive.VelocimacroProxy
All Implemented Interfaces:
Cloneable, DirectiveConstants

public class VelocimacroProxy
extends Directive

VelocimacroProxy.java a proxy Directive-derived object to fit with the current directive system

Version:
$Id: VelocimacroProxy.java 191743 2005-06-21 23:22:20Z dlr $
Author:
Geir Magnusson Jr.

Field Summary
 
Fields inherited from class org.apache.velocity.runtime.directive.Directive
rsvc
 
Fields inherited from interface org.apache.velocity.runtime.directive.DirectiveConstants
BLOCK, LINE
 
Constructor Summary
VelocimacroProxy()
           
 
Method Summary
 String getName()
          Return name of this Velocimacro.
 int getNumArgs()
          returns the number of args needed for this VM
 int getType()
          Velocimacros are always LINE type directives.
 void init(RuntimeServices rs, InternalContextAdapter context, Node node)
          The major meat of VelocimacroProxy, init() checks the # of arguments, patches the macro body, renders the macro into an AST, and then inits the AST, so it is ready for quick rendering.
 boolean render(InternalContextAdapter context, Writer writer, Node node)
          Renders the macro using the context
 void setArgArray(String[] arr)
          sets the array of arguments specified in the macro definition
 void setMacrobody(String mb)
          Sets the orignal macro body.
 void setName(String name)
          sets the directive name of this VM
 void setNamespace(String ns)
           
 void setNodeTree(SimpleNode tree)
           
 boolean setupMacro(String[] callArgs, int[] callArgTypes)
          basic VM setup.
 
Methods inherited from class org.apache.velocity.runtime.directive.Directive
getColumn, getLine, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VelocimacroProxy

public VelocimacroProxy()
Method Detail

getName

public String getName()
Return name of this Velocimacro.

Specified by:
getName in class Directive

getType

public int getType()
Velocimacros are always LINE type directives.

Specified by:
getType in class Directive

setName

public void setName(String name)
sets the directive name of this VM


setArgArray

public void setArgArray(String[] arr)
sets the array of arguments specified in the macro definition


setNodeTree

public void setNodeTree(SimpleNode tree)

getNumArgs

public int getNumArgs()
returns the number of args needed for this VM


setMacrobody

public void setMacrobody(String mb)
Sets the orignal macro body. This is simply the cat of the macroArray, but the Macro object creates this once during parsing, and everyone shares it. Note : it must not be modified.


setNamespace

public void setNamespace(String ns)

render

public boolean render(InternalContextAdapter context,
                      Writer writer,
                      Node node)
               throws MethodInvocationException
Renders the macro using the context

Specified by:
render in class Directive
Throws:
MethodInvocationException

init

public void init(RuntimeServices rs,
                 InternalContextAdapter context,
                 Node node)
          throws Exception
The major meat of VelocimacroProxy, init() checks the # of arguments, patches the macro body, renders the macro into an AST, and then inits the AST, so it is ready for quick rendering. Note that this is only AST dependant stuff. Not context.

Overrides:
init in class Directive
Throws:
Exception

setupMacro

public boolean setupMacro(String[] callArgs,
                          int[] callArgTypes)
basic VM setup. Sets up the proxy args for this use, and parses the tree



Copyright © 2002 Apache Software Foundation. All Rights Reserved.