org.apache.velocity.runtime.directive

Class VelocimacroProxy

public class VelocimacroProxy extends Directive

VelocimacroProxy.java a proxy Directive-derived object to fit with the current directive system

Version: $Id: VelocimacroProxy.java,v 1.27.4.1 2004/03/03 23:22:56 geirm Exp $

Author: Geir Magnusson Jr.

Field Summary
String[]argArray
String[]callingArgs
int[]callingArgTypes
booleaninit
StringmacroBody
StringmacroName
Stringnamespace
SimpleNodenodeTree
intnumMacroArgs
HashMapproxyArgHash
Method Summary
String[]getArgArray(Node node)
gets the args to the VM from the instance-use AST
StringgetName()
Return name of this Velocimacro.
intgetNumArgs()
returns the number of ars needed for this VM
intgetType()
Velocimacros are always LINE type directives.
voidinit(RuntimeServices rs, InternalContextAdapter context, Node node)
The major meat of VelocimacroProxy, init() checks the # of arguments, patches the macro body, renders the macro into an AST, and then inits the AST, so it is ready for quick rendering.
voidparseTree(String[] callArgs)
parses the macro.
booleanrender(InternalContextAdapter context, Writer writer, Node node)
Renders the macro using the context
voidsetArgArray(String[] arr)
sets the array of arguments specified in the macro definition
voidsetMacrobody(String mb)
Sets the orignal macro body.
voidsetName(String name)
sets the directive name of this VM
voidsetNamespace(String ns)
voidsetNodeTree(SimpleNode tree)
booleansetupMacro(String[] callArgs, int[] callArgTypes)
basic VM setup.
voidsetupProxyArgs(String[] callArgs, int[] callArgTypes)

Field Detail

argArray

private String[] argArray

callingArgs

private String[] callingArgs

callingArgTypes

private int[] callingArgTypes

init

private boolean init

macroBody

private String macroBody

macroName

private String macroName

namespace

private String namespace

nodeTree

private SimpleNode nodeTree

numMacroArgs

private int numMacroArgs

proxyArgHash

private HashMap proxyArgHash

Method Detail

getArgArray

private String[] getArgArray(Node node)
gets the args to the VM from the instance-use AST

getName

public String getName()
Return name of this Velocimacro.

getNumArgs

public int getNumArgs()
returns the number of ars needed for this VM

getType

public int getType()
Velocimacros are always LINE type directives.

init

public void init(RuntimeServices rs, InternalContextAdapter context, Node node)
The major meat of VelocimacroProxy, init() checks the # of arguments, patches the macro body, renders the macro into an AST, and then inits the AST, so it is ready for quick rendering. Note that this is only AST dependant stuff. Not context.

parseTree

private void parseTree(String[] callArgs)
parses the macro. We need to do this here, at init time, or else the local-scope template feature is hard to get to work :)

render

public boolean render(InternalContextAdapter context, Writer writer, Node node)
Renders the macro using the context

setArgArray

public void setArgArray(String[] arr)
sets the array of arguments specified in the macro definition

setMacrobody

public void setMacrobody(String mb)
Sets the orignal macro body. This is simply the cat of the macroArray, but the Macro object creates this once during parsing, and everyone shares it. Note : it must not be modified.

setName

public void setName(String name)
sets the directive name of this VM

setNamespace

public void setNamespace(String ns)

setNodeTree

public void setNodeTree(SimpleNode tree)

setupMacro

public boolean setupMacro(String[] callArgs, int[] callArgTypes)
basic VM setup. Sets up the proxy args for this use, and parses the tree

setupProxyArgs

private void setupProxyArgs(String[] callArgs, int[] callArgTypes)
Copyright B) 2002 Apache Software Foundation. All Rights Reserved.