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 754562 2009-03-14 23:59:44Z byron $
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
protected  void checkArgumentCount(Node node, int callArgNum)
          Check whether the number of arguments given matches the number defined.
protected  void checkDepth(InternalContextAdapter context)
          check that we aren't already at the max call depth and throws a MacroOverflowException if we are there.
 List<Macro.MacroArg> getMacroArgs()
          Return the list of macro arguments associated with this macro
 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.
protected  Object[][] handleArgValues(InternalContextAdapter context, Node node, int callArgNum)
          Gets the macro argument values and puts them in the context under the argument names.
 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 setMacroArgs(List<Macro.MacroArg> args)
          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
checkArgs, 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 -

setMacroArgs

public void setMacroArgs(List<Macro.MacroArg> args)
sets the array of arguments specified in the macro definition

Parameters:
args - Array of macro arguments, containing the #macro() arguments and default values. the 0th is the name.

getMacroArgs

public List<Macro.MacroArg> getMacroArgs()
Return the list of macro arguments associated with this macro


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

init

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


render

public boolean render(InternalContextAdapter context,
                      Writer writer,
                      Node node)
               throws IOException
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

render

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

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

checkArgumentCount

protected void checkArgumentCount(Node node,
                                  int callArgNum)
Check whether the number of arguments given matches the number defined.


checkDepth

protected void checkDepth(InternalContextAdapter context)
check that we aren't already at the max call depth and throws a MacroOverflowException if we are there.


handleArgValues

protected Object[][] handleArgValues(InternalContextAdapter context,
                                     Node node,
                                     int callArgNum)
Gets the macro argument values and puts them in the context under the argument names. Store and return an array of old and new values paired for each argument name, for later cleanup.



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