Class VelocimacroProxy
java.lang.Object
org.apache.velocity.runtime.directive.Directive
org.apache.velocity.runtime.directive.VelocimacroProxy
- All Implemented Interfaces:
Cloneable,DirectiveConstants
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 interface org.apache.velocity.runtime.directive.DirectiveConstants
BLOCK, LINE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckArgumentCount(Node node, int callArgNum) Check whether the number of arguments given matches the number defined.protected voidcheckDepth(InternalContextAdapter context) check that we aren't already at the max call depth and throws a MacroOverflowException if we are there.Return the list of macro arguments associated with this macrogetName()Return name of this Velocimacro.intreturns the number of ars needed for this VMintgetType()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.voidinit(RuntimeServices rs) Initialize members of VelocimacroProxy.booleanrender(InternalContextAdapter context, Writer writer, Node node) Render the macro AST nodebooleanrender(InternalContextAdapter context, Writer writer, Node node, Renderable body) Renders the macro using the context.voidsetMacroArgs(List<Macro.MacroArg> args) sets the array of arguments specified in the macro definitionvoidsets the directive name of this VMvoidsetNodeTree(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
-
Constructor Details
-
VelocimacroProxy
public VelocimacroProxy()
-
-
Method Details
-
getName
Return name of this Velocimacro. -
getType
public int getType()Velocimacros are always LINE type directives. -
setName
sets the directive name of this VM- Parameters:
name-
-
setMacroArgs
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
Return the list of macro arguments associated with this macro- Returns:
- macro arguments
-
setNodeTree
- 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
Initialize members of VelocimacroProxy. called from MacroEntry- Parameters:
rs- runtime services
-
render
Render the macro AST node- Specified by:
renderin classDirective- 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 contextwriter- Writer for outputnode- AST that calls the macrobody- the macro body- Returns:
- true if the directive rendered successfully.
- Throws:
IOException
-
checkArgumentCount
Check whether the number of arguments given matches the number defined.- Parameters:
node-callArgNum-
-
checkDepth
check that we aren't already at the max call depth and throws a MacroOverflowException if we are there.- Parameters:
context-
-
handleArgValues
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
-