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 898032 2010-01-11 19:51:03Z nbubna $
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
 void checkArgs(InternalContextAdapter context, Node node, boolean hasBody)
          check if we are calling this macro with the right number of arguments.
 String getName()
          Return name of this Velocimacro.
 int getNumArgs()
          returns the number of ars needed for this VM
 int getType()
          Velocimacros are always LINE type directives.
 void init(RuntimeServices rs)
          Initialize members of VelocimacroProxy.
 boolean render(InternalContextAdapter context, Writer writer, Node node)
          How this directive is to be rendered
 boolean render(InternalContextAdapter context, Writer writer, Node node, Renderable body)
          Renders the macro using the context.
 void setArgArray(String[] arr)
          sets the array of arguments specified in the macro definition
 void setName(String name)
          sets the directive name of this VM
 void setNodeTree(SimpleNode tree)
           
 
Methods inherited from class org.apache.velocity.runtime.directive.Directive
getColumn, getLine, getScopeName, getTemplateName, init, isScopeProvided, makeScope, postRender, preRender, setLocation, 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
Returns:
The name of this Velocimacro.

getType

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

Specified by:
getType in class Directive
Returns:
The type of this directive.

setName

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

Parameters:
name -

setArgArray

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

Parameters:
arr -

setNodeTree

public void setNodeTree(SimpleNode tree)
Parameters:
tree -

getNumArgs

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

Returns:
The number of ars needed for this VM

render

public boolean render(InternalContextAdapter context,
                      Writer writer,
                      Node node)
               throws IOException,
                      MethodInvocationException,
                      MacroOverflowException
Description copied from class: Directive
How this directive is to be rendered

Specified by:
render in class Directive
Returns:
True if the directive rendered successfully.
Throws:
IOException
MethodInvocationException
MacroOverflowException

render

public boolean render(InternalContextAdapter context,
                      Writer writer,
                      Node node,
                      Renderable body)
               throws IOException,
                      MethodInvocationException,
                      MacroOverflowException
Renders the macro using the context.

Parameters:
context - Current rendering context
writer - Writer for output
node - AST that calls the macro
Returns:
True if the directive rendered successfully.
Throws:
IOException
MethodInvocationException
MacroOverflowException

init

public void init(RuntimeServices rs)
Initialize members of VelocimacroProxy. called from MacroEntry


checkArgs

public void checkArgs(InternalContextAdapter context,
                      Node node,
                      boolean hasBody)
check if we are calling this macro with the right number of arguments. If we are not, and strictArguments is active, then throw TemplateInitException. This method is called during macro render, so it must be thread safe.



Copyright © 2000-2010 The Apache Software Foundation. All Rights Reserved.