Class Macro
- java.lang.Object
-
- org.apache.velocity.runtime.directive.Directive
-
- org.apache.velocity.runtime.directive.Macro
-
- All Implemented Interfaces:
java.lang.Cloneable
,DirectiveConstants
public class Macro extends Directive
Macro implements the macro definition directive of VTL. example : #macro( isnull $i ) #if( $i ) $i #end #end This object is used at parse time to mainly process and register the macro. It is used inline in the parser when processing a directive.- Version:
- $Id: Macro.java 746438 2009-02-21 05:41:24Z nbubna $
-
-
Constructor Summary
Constructors Constructor Description Macro()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
checkArgs(RuntimeServices rs, Token t, Node node, java.lang.String sourceTemplate)
Used by Parser.java to do further parameter checking for macro arguments.private static java.lang.String[]
getArgArray(Node node, RuntimeServices rsvc)
Creates an array containing the literal text from the macro arguement(s) (including the macro's name as the first arg).java.lang.String
getName()
Return name of this directive.int
getType()
Return type of this directive.void
init(RuntimeServices rs, InternalContextAdapter context, Node node)
How this directive is to be initialized.boolean
isScopeProvided()
Since this class does no processing of content, there is never a need for an internal scope.static java.lang.StringBuffer
macroToString(java.lang.StringBuffer buf, java.lang.String[] argArray)
For debugging purposes.boolean
render(InternalContextAdapter context, java.io.Writer writer, Node node)
render() doesn't do anything in the final output rendering.-
Methods inherited from class org.apache.velocity.runtime.directive.Directive
getColumn, getLine, getScopeName, getTemplateName, makeScope, postRender, preRender, setLocation, setLocation
-
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Return name of this directive.
-
getType
public int getType()
Return type of this directive.
-
isScopeProvided
public boolean isScopeProvided()
Since this class does no processing of content, there is never a need for an internal scope.- Overrides:
isScopeProvided
in classDirective
- Returns:
- true if there will be a scope control injected into the context when rendering this directive.
-
render
public boolean render(InternalContextAdapter context, java.io.Writer writer, Node node) throws java.io.IOException
render() doesn't do anything in the final output rendering. There is no output from a #macro() directive.
-
init
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException
Description copied from class:Directive
How this directive is to be initialized.
-
checkArgs
public static void checkArgs(RuntimeServices rs, Token t, Node node, java.lang.String sourceTemplate) throws java.io.IOException, ParseException
Used by Parser.java to do further parameter checking for macro arguments.- Throws:
java.io.IOException
ParseException
-
getArgArray
private static java.lang.String[] getArgArray(Node node, RuntimeServices rsvc)
Creates an array containing the literal text from the macro arguement(s) (including the macro's name as the first arg).- Parameters:
node
- The parse node from which to grok the argument list. It's expected to include the block node tree (for the macro body).rsvc
- For debugging purposes only.- Returns:
- array of arguments
-
macroToString
public static final java.lang.StringBuffer macroToString(java.lang.StringBuffer buf, java.lang.String[] argArray)
For debugging purposes. Formats the arguments fromargArray
and appends them tobuf
.- Parameters:
buf
- A StringBuffer. If null, a new StringBuffer is allocated.argArray
- The Macro arguments to format- Returns:
- A StringBuffer containing the formatted arguments. If a StringBuffer has passed in as buf, this method returns it.
- Since:
- 1.5
-
-