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 Macro

    java.lang.Object
      org.apache.velocity.runtime.directive.Directive
          org.apache.velocity.runtime.directive.Macro

All Implemented Interfaces:
  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 $
Author:
  Geir Magnusson Jr., Henning P. Schmiedehausen

Field Summary

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
`static void` | `checkArgs(RuntimeServices rs, Token t, Node node, String sourceTemplate)` Used by Parser.java to do further parameter checking for macro arguments.
`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 StringBuffer` | `macroToString(StringBuffer buf, String[] argArray)` For debugging purposes.
`boolean` | `render(InternalContextAdapter context, 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`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Macro

    public Macro()

Method Detail

### getName

    public String getName()

  Return name of this directive.

  Specified by:
    `getName` in class `Directive`
  Returns:
    The name of this directive.

### getType

    public int getType()

  Return type of this directive.

  Specified by:
    `getType` in class `Directive`
  Returns:
    The 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 class `Directive`
  Returns:
    true if there will be a scope control injected into the context when rendering this directive.

### render

    public boolean render(InternalContextAdapter context,
                          Writer writer,
                          Node node)
                   throws 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`
  Parameters:
    `context` -
    `writer` -
    `node` -
  Returns:
    True if the directive rendered successfully.
  Throws:
    `IOException`

### init

    public void init(RuntimeServices rs,
                     InternalContextAdapter context,
                     Node node)
              throws TemplateInitException

  Description copied from class: `Directive`
  How this directive is to be initialized.

  Overrides:
    `init` in class `Directive`
  Parameters:
    `rs` -
    `context` -
    `node` -
  Throws:
    `TemplateInitException`
  See Also:
    `Directive.init(org.apache.velocity.runtime.RuntimeServices, org.apache.velocity.context.InternalContextAdapter, org.apache.velocity.runtime.parser.node.Node)`

### checkArgs

    public static void checkArgs(RuntimeServices rs,
                                 Token t,
                                 Node node,
                                 String sourceTemplate)
                          throws IOException,
                                 ParseException

  Used by Parser.java to do further parameter checking for macro arguments.

  Throws:
    `IOException`
    `ParseException`

### macroToString

    public static final StringBuffer macroToString(StringBuffer buf,
                                                   String[] argArray)

  For debugging purposes. Formats the arguments from `argArray` and appends them to `buf`.

  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

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 © 2000-2010 Apache Software Foundation. All Rights Reserved.