freemarker.template.instruction
Class IfInstruction

java.lang.Object
  extended by freemarker.template.instruction.ElseInstruction
      extended by freemarker.template.instruction.IfInstruction
All Implemented Interfaces:
Instruction, TemplateProcessor, java.io.Serializable

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 1153 2013-04-15 10:59:37Z run2000 $
See Also:
IfElseInstruction, ElseInstruction, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface freemarker.template.instruction.Instruction
Instruction.EndType
 
Nested classes/interfaces inherited from interface freemarker.template.TemplateProcessor
TemplateProcessor.ExitStatus
 
Field Summary
 
Fields inherited from class freemarker.template.instruction.ElseInstruction
body
 
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(TemplateWriteableHashModel modelRoot)
          Tests the condition for which this "if" statement should match.
 Instruction.EndType 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:
java.lang.NullPointerException - condition is null
Method Detail

conditionMatches

public boolean conditionMatches(TemplateWriteableHashModel modelRoot)
                         throws TemplateException
Tests the condition for which this "if" statement should match.

Overrides:
conditionMatches in class ElseInstruction
Returns:
the condition to be tested
Throws:
TemplateException

getEndType

public Instruction.EndType getEndType()
Determine what type of end instruction this is, if any.

Specified by:
getEndType in interface Instruction
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