Package org.apache.velocity.runtime.directive

# Class VelocimacroProxy

java.lang.Object
org.apache.velocity.runtime.directive.Directive
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$
Author:
  Geir Magnusson Jr.

## Field Summary

### Fields inherited from class org.apache.velocity.runtime.directive.Directive

`log, rsvc`

### Fields inherited from interface org.apache.velocity.runtime.directive.DirectiveConstants

`BLOCK, LINE`

## Constructor Summary

Constructors
Constructor
Description
`VelocimacroProxy()`

## Method Summary

Modifier and Type
Method
Description
`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)`
Render the macro AST node
`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, getTemplate, 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 Details

### VelocimacroProxy

public VelocimacroProxy()

## Method Details

### 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

Returns:
  macro arguments

### 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

Parameters:
  `rs` - runtime services

### render

public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException
Render the macro AST node

Specified by:
  `render` in class `Directive`
Parameters:
  `context` -
  `writer` -
  `node` -
Returns:
  success status
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.

Parameters:
  `node` -
  `callArgNum` -

### 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.

Parameters:
  `context` -

### 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. Also, put literal representations of arguments which evaluate to null in the context.

Parameters:
  `context` -
  `node` -
  `callArgNum` -
Returns:
  macro arguments values