freemarker.template.instruction
Class DefaultCaseInstruction

java.lang.Object
  |
  +--freemarker.template.instruction.DefaultCaseInstruction
All Implemented Interfaces:
Instruction, java.io.Serializable, TemplateProcessor
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,v 1.9 2003/11/27 11:36:45 run2000 Exp $
See Also:
CaseInstruction, SwitchInstruction, Serialized Form

Field Summary
protected  TemplateProcessor body
          The template body to process if the default case is reached.
 
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
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.
 int getEndType()
          Retrieve the type of end instruction, if any.
 Expression getExpression()
          Retrieves the Expression to be evaluated when the case instruction is encountered.
 boolean hasBreak()
          Does this case instruction contain a break instruction?
 boolean isDefault()
          Is this the default case?
 boolean isEndInstruction()
          Is this an end instruction?
 void process(TemplateModelRoot modelRoot, java.io.Writer out, TemplateRuntimeHandler eventHandler)
          Process this <default> instruction.
 void setBody(TemplateProcessor body)
          Sets the body to be processed if the case expression evaluated to true.
 void setBreak(boolean hasBreak)
          Sets whether this case instruction contains a break instruction.
 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.

setBreak

public void setBreak(boolean hasBreak)
Sets whether this case instruction contains a break instruction.
Parameters:
hasBreak - true if this CaseInstruction has a break, otherwise false

hasBreak

public boolean hasBreak()
Does this case instruction contain a break instruction?
Returns:
true if this Case has a break instruction, otherwise false

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 int 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 void process(TemplateModelRoot modelRoot,
                          java.io.Writer out,
                          TemplateRuntimeHandler eventHandler)
                   throws java.io.IOException
Process this <default> instruction.
Specified by:
process in interface TemplateProcessor
Parameters:
modelRoot - the root node of the data model.
out - a Writer to send the output to.
eventHandler - a TemplateEventAdapter for handling any events that occur 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