org.apache.velocity.runtime.directive
Class Macro

java.lang.Object
  extended byorg.apache.velocity.runtime.directive.Directive
      extended byorg.apache.velocity.runtime.directive.Macro
All Implemented Interfaces:
java.lang.Cloneable, DirectiveConstants

public class Macro
extends Directive

Macro.java 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,v 1.16.4.1 2004/03/03 23:22:56 geirm Exp $
Author:
Geir Magnusson Jr.

Field Summary
private static boolean debugMode
           
 
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
Macro()
           
 
Method Summary
private static java.lang.String[] getArgArray(Node node)
          creates an array containing the literal strings in the macro arguement
private static java.util.List getASTAsStringArray(Node rootNode)
          Returns an array of the literal rep of the AST
 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.
static void processAndRegister(RuntimeServices rs, Node node, java.lang.String sourceTemplate)
          Used by Parser.java to process VMs withing the parsing process processAndRegister() doesn't actually render the macro to the output Processes the macro body into the internal representation used by the VelocimacroProxy objects, and if not currently used, adds it to the macro Factory
 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, setLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debugMode

private static boolean debugMode
Constructor Detail

Macro

public Macro()
Method Detail

getName

public java.lang.String getName()
Return name of this directive.

Specified by:
getName in class Directive

getType

public int getType()
Return type of this directive.

Specified by:
getType in class 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.

Specified by:
render in class Directive
Throws:
java.io.IOException

init

public void init(RuntimeServices rs,
                 InternalContextAdapter context,
                 Node node)
          throws java.lang.Exception
Description copied from class: Directive
How this directive is to be initialized.

Overrides:
init in class Directive
Throws:
java.lang.Exception

processAndRegister

public static void processAndRegister(RuntimeServices rs,
                                      Node node,
                                      java.lang.String sourceTemplate)
                               throws java.io.IOException,
                                      ParseException
Used by Parser.java to process VMs withing the parsing process processAndRegister() doesn't actually render the macro to the output Processes the macro body into the internal representation used by the VelocimacroProxy objects, and if not currently used, adds it to the macro Factory

Throws:
java.io.IOException
ParseException

getArgArray

private static java.lang.String[] getArgArray(Node node)
creates an array containing the literal strings in the macro arguement


getASTAsStringArray

private static java.util.List getASTAsStringArray(Node rootNode)
Returns an array of the literal rep of the AST



Copyright © 2002 Apache Software Foundation. All Rights Reserved.