org.apache.velocity.runtime.directive
Class Define

java.lang.Object
  extended by org.apache.velocity.runtime.directive.Directive
      extended by org.apache.velocity.runtime.directive.Define
All Implemented Interfaces:
Cloneable, DirectiveConstants

public class Define
extends Directive

Directive that puts an unrendered AST block in the context under the specified key, postponing rendering until the reference is used and rendered.

Version:
$Id: Define.java 686842 2008-08-18 18:29:31Z nbubna $
Author:
Andrew Tetlaw, Nathan Bubna

Nested Class Summary
static class Define.Block
          actual class placed in the context, holds the context and writer being used for the render, as well as the parent (which already holds everything else we need).
 
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
Define()
           
 
Method Summary
 String getName()
          Return name of this directive.
 int getType()
          Return type of this directive.
protected  String id(InternalContextAdapter context)
          Creates a string identifying the source and location of the block definition, and the current template being rendered if that is different.
 void init(RuntimeServices rs, InternalContextAdapter context, Node node)
          simple init - get the key
 boolean render(InternalContextAdapter context, Writer writer, Node node)
          directive.render() simply makes an instance of the Block inner class and places it into the context as indicated.
 
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
 

Constructor Detail

Define

public Define()
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 directive type BLOCK/LINE.

init

public void init(RuntimeServices rs,
                 InternalContextAdapter context,
                 Node node)
          throws TemplateInitException
simple init - get the key

Overrides:
init in class Directive
Throws:
TemplateInitException

render

public boolean render(InternalContextAdapter context,
                      Writer writer,
                      Node node)
directive.render() simply makes an instance of the Block inner class and places it into the context as indicated.

Specified by:
render in class Directive
Returns:
True if the directive rendered successfully.

id

protected String id(InternalContextAdapter context)
Creates a string identifying the source and location of the block definition, and the current template being rendered if that is different.



Copyright © 2000-2008 The Apache Software Foundation. All Rights Reserved.