VelocimacroProxy (Velocity 1.4 API)
Keywords: org.apache.velocity.runtime.directive.VelocimacroProxy class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.velocity.runtime.directive
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,v 1.27.4.1 2004/03/03 23:22:56 geirm Exp $
Author:
  Geir Magnusson Jr.

Field Summary
`private java.lang.String[]` | `argArray`
`private java.lang.String[]` | `callingArgs`
`private int[]` | `callingArgTypes`
`private boolean` | `init`
`private java.lang.String` | `macroBody`
`private java.lang.String` | `macroName`
`private java.lang.String` | `namespace`
`private SimpleNode` | `nodeTree`
`private int` | `numMacroArgs`
`private java.util.HashMap` | `proxyArgHash`

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
`VelocimacroProxy()`

Method Summary
`private java.lang.String[]` | `getArgArray(Node node)` gets the args to the VM from the instance-use AST
`java.lang.String` | `getName()` Return name of this Velocimacro.
`int` | `getNumArgs()` returns the number of ars needed for this VM
`int` | `getType()` Velocimacros are always LINE type directives.
`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.
`private void` | `parseTree(java.lang.String[] callArgs)` parses the macro.
`boolean` | `render(InternalContextAdapter context, java.io.Writer writer, Node node)` Renders the macro using the context
`void` | `setArgArray(java.lang.String[] arr)` sets the array of arguments specified in the macro definition
`void` | `setMacrobody(java.lang.String mb)` Sets the orignal macro body.
`void` | `setName(java.lang.String name)` sets the directive name of this VM
`void` | `setNamespace(java.lang.String ns)`
`void` | `setNodeTree(SimpleNode tree)`
`boolean` | `setupMacro(java.lang.String[] callArgs, int[] callArgTypes)` basic VM setup.
`private void` | `setupProxyArgs(java.lang.String[] callArgs, int[] callArgTypes)`

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

### macroName

    private java.lang.String macroName

### macroBody

    private java.lang.String macroBody

### argArray

    private java.lang.String[] argArray

### nodeTree

    private SimpleNode nodeTree

### numMacroArgs

    private int numMacroArgs

### namespace

    private java.lang.String namespace

### init

    private boolean init

### callingArgs

    private java.lang.String[] callingArgs

### callingArgTypes

    private int[] callingArgTypes

### proxyArgHash

    private java.util.HashMap proxyArgHash

Constructor Detail

### VelocimacroProxy

    public VelocimacroProxy()

Method Detail

### getName

    public java.lang.String getName()

  Return name of this Velocimacro.

  Specified by:
    `getName` in class `Directive`

### getType

    public int getType()

  Velocimacros are always LINE type directives.

  Specified by:
    `getType` in class `Directive`

### setName

    public void setName(java.lang.String name)

  sets the directive name of this VM

### setArgArray

    public void setArgArray(java.lang.String[] arr)

  sets the array of arguments specified in the macro definition

### setNodeTree

    public void setNodeTree(SimpleNode tree)

### getNumArgs

    public int getNumArgs()

  returns the number of ars needed for this VM

### setMacrobody

    public void setMacrobody(java.lang.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.

### setNamespace

    public void setNamespace(java.lang.String ns)

### render

    public boolean render(InternalContextAdapter context,
                          java.io.Writer writer,
                          Node node)
                   throws java.io.IOException,
                          MethodInvocationException

  Renders the macro using the context

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

### init

    public void init(RuntimeServices rs,
                     InternalContextAdapter context,
                     Node node)
              throws java.lang.Exception

  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.

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

### setupMacro

    public boolean setupMacro(java.lang.String[] callArgs,
                              int[] callArgTypes)

  basic VM setup. Sets up the proxy args for this use, and parses the tree

### parseTree

    private void parseTree(java.lang.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 :)

### setupProxyArgs

    private void setupProxyArgs(java.lang.String[] callArgs,
                                int[] callArgTypes)

### getArgArray

    private java.lang.String[] getArgArray(Node node)

  gets the args to the VM from the instance-use AST

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 Apache Software Foundation. All Rights Reserved.