freemarker.template.instruction
Class IfInstruction
java.lang.Object
freemarker.template.instruction.ElseInstruction
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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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
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