org.apache.velocity.runtime.directive
Class Break

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

public class Break
extends Directive

Break directive used for interrupting foreach loops.

Version:
$Id$
Author:
Jarkko Viinamaki

Nested Class Summary
static class Break.BreakException
           
 
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
Break()
           
 
Method Summary
 String getName()
          Return name of this directive.
 int getType()
          Return type of this directive.
 void init(RuntimeServices rs, InternalContextAdapter context, Node node)
          simple init - init the tree and get the elementKey from the AST
 boolean render(InternalContextAdapter context, Writer writer, Node node)
          Break directive does not actually do any 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
 

Constructor Detail

Break

public Break()
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.

init

public void init(RuntimeServices rs,
                 InternalContextAdapter context,
                 Node node)
          throws TemplateInitException
simple init - init the tree and get the elementKey from the AST

Overrides:
init in class Directive
Parameters:
rs -
context -
node -
Throws:
TemplateInitException

render

public boolean render(InternalContextAdapter context,
                      Writer writer,
                      Node node)
               throws IOException,
                      MethodInvocationException,
                      ResourceNotFoundException,
                      ParseErrorException
Break directive does not actually do any rendering. This directive throws a BreakException (RuntimeException) which signals foreach directive to break out of the loop. Note that this directive does not verify that it is being called inside a foreach loop.

Specified by:
render in class Directive
Parameters:
context -
writer -
node -
Returns:
true if the directive rendered successfully.
Throws:
IOException
MethodInvocationException
ResourceNotFoundException
ParseErrorException


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