freemarker.template.instruction
Class DefaultCaseInstruction

java.lang.Object
  extended by freemarker.template.instruction.DefaultCaseInstruction
All Implemented Interfaces:
Instruction, TemplateProcessor, java.io.Serializable
Direct Known Subclasses:
CaseInstruction

public class DefaultCaseInstruction
extends java.lang.Object
implements TemplateProcessor, Instruction, java.io.Serializable

Represents a case in a switch statement. Unexpectedly, this is a superclass for the regular CaseInstruction class.

Version:
$Id: DefaultCaseInstruction.java 1162 2013-04-20 12:04:32Z run2000 $
See Also:
CaseInstruction, SwitchInstruction, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface freemarker.template.TemplateProcessor
TemplateProcessor.ExitStatus
 
Nested classes/interfaces inherited from interface freemarker.template.instruction.Instruction
Instruction.EndType
 
Field Summary
protected  TemplateProcessor body
          The template body to process if the default case is reached.
 
Constructor Summary
DefaultCaseInstruction()
          Default constructor.
 
Method Summary
 TemplateProcessor callBuilder(TemplateBuilder builder)
          A TemplateBuilder can call this method to have an Instruction call it back to be built.
 Instruction.EndType getEndType()
          Retrieve the type of end instruction, if any.
 Expression getExpression()
          Retrieves the Expression to be evaluated when the case instruction is encountered.
 boolean isDefault()
          Is this the default case?
 boolean isEndInstruction()
          Is this an end instruction?
 TemplateProcessor.ExitStatus process(TemplateProcessorParameters p)
          Process this <default> instruction.
 void setBody(TemplateProcessor body)
          Sets the body to be processed if the case expression evaluated to true.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

body

protected TemplateProcessor body
The template body to process if the default case is reached.

Constructor Detail

DefaultCaseInstruction

public DefaultCaseInstruction()
Default constructor.

Method Detail

getExpression

public Expression getExpression()
Retrieves the Expression to be evaluated when the case instruction is encountered.

Returns:
the Expression associated with this CaseInstruction

isDefault

public boolean isDefault()
Is this the default case?

Returns:
true if this is the default case, otherwise false

setBody

public final void setBody(TemplateProcessor body)
Sets the body to be processed if the case expression evaluated to true.

Parameters:
body - the TemplateProcessor to be processed if this Case passes the test.

isEndInstruction

public final boolean isEndInstruction()
Is this an end instruction?

Specified by:
isEndInstruction in interface Instruction
Returns:
true, to indicate this is an end instruction

getEndType

public Instruction.EndType getEndType()
Retrieve the type of end instruction, if any.

Specified by:
getEndType in interface Instruction
Returns:
DEFAULT

callBuilder

public final TemplateProcessor callBuilder(TemplateBuilder builder)
A TemplateBuilder can call this method to have an Instruction call it back to be built. For end instructions, there is nothing more to be build, so return immediately.

Specified by:
callBuilder in interface Instruction
Parameters:
builder - the builder to be called back by this method

process

public final TemplateProcessor.ExitStatus process(TemplateProcessorParameters p)
                                           throws java.io.IOException
Process this <default> instruction.

Specified by:
process in interface TemplateProcessor
Parameters:
p - template processing parameters
Returns:
an exit code indicating how the process terminated, typically used for short-circuiting template processing
Throws:
java.io.IOException - an IO error occurred during processing

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a String representing this instruction subtree