freemarker.template.instruction
Class LocalInstruction

java.lang.Object
  extended by freemarker.template.instruction.GenericStartInstruction
      extended by freemarker.template.instruction.LocalInstruction
All Implemented Interfaces:
FunctionTemplateProcessor, ContainerInstruction, Instruction, TemplateProcessor, java.io.Serializable

public final class LocalInstruction
extends GenericStartInstruction
implements FunctionTemplateProcessor, java.io.Serializable

An instruction representing a local instruction.

Since:
1.9
Version:
$Id: LocalInstruction.java 1162 2013-04-20 12:04:32Z run2000 $
Author:
Nicholas Cull
See Also:
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
 
Fields inherited from class freemarker.template.instruction.GenericStartInstruction
body
 
Constructor Summary
LocalInstruction(java.util.List<Identifier> localVariables)
          Constructor that takes a list of local variable identifiers to indicate which variables should be interpreted as local to this scope.
 
Method Summary
 void addFunction(java.lang.String name, TemplateFunctionModel function)
          Adds an inner function to this function.
 TemplateProcessor callBuilder(TemplateBuilder builder)
          Call the TemplateBuilder with this local instruction.
 TemplateFunctionModel getFunction(java.lang.String name)
          Retrieves an inner function from this function.
 java.util.Set<java.lang.String> getFunctionNames()
          Retrieve a Set of inner function names for this function.
 TemplateProcessor.ExitStatus process(TemplateProcessorParameters p)
          Evaluate this <local> instruction.
 boolean testEndInstruction(Instruction endInstruction)
          Is this the right kind of instruction for the given EndInstruction?
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class freemarker.template.instruction.GenericStartInstruction
getEndType, isEndInstruction, setBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalInstruction

public LocalInstruction(java.util.List<Identifier> localVariables)
Constructor that takes a list of local variable identifiers to indicate which variables should be interpreted as local to this scope.

Parameters:
localVariables - the list of local variables, or empty to indicate all variables are local
Method Detail

testEndInstruction

public boolean testEndInstruction(Instruction endInstruction)
Is this the right kind of instruction for the given EndInstruction?

Specified by:
testEndInstruction in interface ContainerInstruction
Parameters:
endInstruction - the end instruction we're testing
Returns:
true if the EndInstruction is a local end instruction, otherwise false

process

public TemplateProcessor.ExitStatus process(TemplateProcessorParameters p)
                                     throws java.io.IOException
Evaluate this <local> 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

callBuilder

public TemplateProcessor callBuilder(TemplateBuilder builder)
                              throws ParseException
Call the TemplateBuilder with this local instruction.

Specified by:
callBuilder in interface Instruction
Overrides:
callBuilder in class GenericStartInstruction
Parameters:
builder - the TemplateBuilder to be called back
Throws:
ParseException

getFunction

public TemplateFunctionModel getFunction(java.lang.String name)
Retrieves an inner function from this function. Called by CallInstructions at run-time.

Specified by:
getFunction in interface FunctionTemplateProcessor
Parameters:
name - the name of the function to be retrieved

getFunctionNames

public java.util.Set<java.lang.String> getFunctionNames()
Retrieve a Set of inner function names for this function.

Specified by:
getFunctionNames in interface FunctionTemplateProcessor
Returns:
a Set of inner function names (String objects) that have been defined for this template.

addFunction

public void addFunction(java.lang.String name,
                        TemplateFunctionModel function)
                 throws java.lang.IllegalStateException
Adds an inner function to this function. Called by the TemplateBuilder at compile-time.

Specified by:
addFunction in interface FunctionTemplateProcessor
Parameters:
name - the name of the function to be stored
function - the inner function to be stored by this function
Throws:
java.lang.IllegalStateException - the method has been called after the template has been compiled

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