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.
- See Also:
IfElseInstruction,
ElseInstruction,
Serialized Form
| Fields inherited from interface freemarker.template.instruction.Instruction |
ASSIGN_END, BREAK, CASE, COMMENT_END, COMPRESS_END, DEFAULT, ELSE, ELSEIF, FOREACH_END, FUNCTION_END, IF_END, LIST_END, NONE, NOPARSE_END, SWITCH_END, TRANSFORM_END |
| 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 int 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