freemarker.template.instruction
Class IfInstruction

java.lang.Object
  |
  +--freemarker.template.instruction.ElseInstruction
        |
        +--freemarker.template.instruction.IfInstruction
All Implemented Interfaces:
Instruction, java.io.Serializable, TemplateProcessor

public final class IfInstruction
extends ElseInstruction
implements java.io.Serializable

An instruction representing an if-else structure. The "if" part of the structure will be executed if the condition expression evaluates to true value.

Unexpectedly, this is a subclass of the ElseInstruction class.

Version:
$Id: IfInstruction.java,v 1.24 2003/11/27 07:07:13 run2000 Exp $
See Also:
IfElseInstruction, ElseInstruction, Serialized Form

Fields inherited from class freemarker.template.instruction.ElseInstruction
body
 
Fields inherited from interface freemarker.template.instruction.Instruction
BREAK, CASE, COMMENT_END, COMPRESS_END, DEFAULT, ELSE, ELSEIF, FOREACH_END, FUNCTION_END, IF_END, LIST_END, NONE, NOPARSE_END, SWITCH_END, TRANSFORM_END
 
Constructor Summary
IfInstruction(Expression condition)
          Constructor that takes an Expression to be tested when evaluating the "if" part of the instruction.
 
Method Summary
 boolean conditionMatches(TemplateModelRoot modelRoot)
          Tests the condition for which this "if" statement should match.
 int getEndType()
          Determine what type of end instruction this is, if any.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class freemarker.template.instruction.ElseInstruction
callBuilder, isEndInstruction, process, setBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IfInstruction

public IfInstruction(Expression condition)
Constructor that takes an Expression to be tested when evaluating the "if" part of the instruction.
Parameters:
condition - the condition for the if statement.
Throws:
NullPointerException - condition is null
Method Detail

conditionMatches

public boolean conditionMatches(TemplateModelRoot modelRoot)
                         throws TemplateException
Tests the condition for which this "if" statement should match.
Overrides:
conditionMatches in class ElseInstruction
Returns:
the condition to be tested

getEndType

public int getEndType()
Determine what type of end instruction this is, if any.
Overrides:
getEndType in class ElseInstruction
Returns:
ELSEIF, indicating that this is an elseif instruction

toString

public java.lang.String toString()
Returns a string representation of the object.
Overrides:
toString in class ElseInstruction
Returns:
a String representing this instruction subtree