Class VelocimacroProxy
- java.lang.Object
-
- org.apache.velocity.runtime.directive.Directive
-
- org.apache.velocity.runtime.directive.VelocimacroProxy
-
- All Implemented Interfaces:
java.lang.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 $
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String[]argArrayprivate java.lang.StringbodyReferenceprivate java.lang.String[]literalArgArrayprivate booleanlocalContextScopeprivate java.lang.StringmacroNameprivate intmaxCallDepthprivate SimpleNodenodeTreeprivate intnumMacroArgsprivate booleanstrictArguments-
Fields inherited from interface org.apache.velocity.runtime.directive.DirectiveConstants
BLOCK, LINE
-
-
Constructor Summary
Constructors Constructor Description VelocimacroProxy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringbuildErrorMsg(Node node, int numArgsProvided)Build an error message for not providing the correct number of argumentsvoidcheckArgs(InternalContextAdapter context, Node node, boolean hasBody)check if we are calling this macro with the right number of arguments.java.lang.StringgetName()Return name of this Velocimacro.intgetNumArgs()returns the number of ars needed for this VMintgetType()Velocimacros are always LINE type directives.voidinit(RuntimeServices rs)Initialize members of VelocimacroProxy.booleanrender(InternalContextAdapter context, java.io.Writer writer, Node node)How this directive is to be renderedbooleanrender(InternalContextAdapter context, java.io.Writer writer, Node node, Renderable body)Renders the macro using the context.voidsetArgArray(java.lang.String[] arr)sets the array of arguments specified in the macro definitionvoidsetName(java.lang.String name)sets the directive name of this VMvoidsetNodeTree(SimpleNode tree)-
Methods inherited from class org.apache.velocity.runtime.directive.Directive
getColumn, getLine, getScopeName, getTemplateName, init, isScopeProvided, makeScope, postRender, preRender, setLocation, setLocation
-
-
-
-
Field Detail
-
macroName
private java.lang.String macroName
-
argArray
private java.lang.String[] argArray
-
literalArgArray
private java.lang.String[] literalArgArray
-
nodeTree
private SimpleNode nodeTree
-
numMacroArgs
private int numMacroArgs
-
strictArguments
private boolean strictArguments
-
localContextScope
private boolean localContextScope
-
maxCallDepth
private int maxCallDepth
-
bodyReference
private java.lang.String bodyReference
-
-
Method Detail
-
getName
public java.lang.String getName()
Return name of this Velocimacro.
-
getType
public int getType()
Velocimacros are always LINE type directives.
-
setName
public void setName(java.lang.String name)
sets the directive name of this VM- Parameters:
name-
-
setArgArray
public void setArgArray(java.lang.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, java.io.Writer writer, Node node) throws java.io.IOException, MethodInvocationException, MacroOverflowException
Description copied from class:DirectiveHow this directive is to be rendered- Specified by:
renderin classDirective- Returns:
- True if the directive rendered successfully.
- Throws:
java.io.IOExceptionMethodInvocationExceptionMacroOverflowException
-
render
public boolean render(InternalContextAdapter context, java.io.Writer writer, Node node, Renderable body) throws java.io.IOException, MethodInvocationException, MacroOverflowException
Renders the macro using the context.- Parameters:
context- Current rendering contextwriter- Writer for outputnode- AST that calls the macro- Returns:
- True if the directive rendered successfully.
- Throws:
java.io.IOExceptionMethodInvocationExceptionMacroOverflowException
-
init
public void init(RuntimeServices rs)
Initialize members of VelocimacroProxy. called from MacroEntry
-
buildErrorMsg
private java.lang.String buildErrorMsg(Node node, int numArgsProvided)
Build an error message for not providing the correct number of arguments
-
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.
-
-