koala.dynamicjava.tree
Class ForEachStatement

java.lang.Object
  extended by koala.dynamicjava.tree.Node
      extended by koala.dynamicjava.tree.Statement
          extended by koala.dynamicjava.tree.ForSlashEachStatement
              extended by koala.dynamicjava.tree.ForEachStatement
All Implemented Interfaces:
ContinueTarget, SourceInfo.Wrapper

public class ForEachStatement
extends ForSlashEachStatement
implements ContinueTarget

This class represents the foreach statement nodes of the syntax tree


Constructor Summary
ForEachStatement(FormalParameter para, Expression collection, Node body)
          Creates a new for statement
ForEachStatement(FormalParameter para, Expression coll, Node body, SourceInfo si)
          Creates a new for statement
 
Method Summary
<T> T
acceptVisitor(Visitor<T> visitor)
          Allows a visitor to traverse the tree
 void addLabel(java.lang.String label)
          Adds a label to this statement
 void addVar(java.lang.String s)
           
 Node getBody()
          Returns the body of this statement
 Expression getCollection()
          Gets the condition to evaluate at each loop
 FormalParameter getParameter()
          Gets the initialization statements
 java.util.List<java.lang.String> getVars()
           
 boolean hasLabel(java.lang.String label)
          Test whether this statement has the given label
 void setBody(Node node)
          Sets the body of this statement
 void setCollection(Expression e)
          Sets the condition to evaluate
 void setParameter(FormalParameter l)
          Sets the initialization statements
 java.lang.String toString()
           
 
Methods inherited from class koala.dynamicjava.tree.Node
archiveProperties, getProperties, getProperty, getSourceInfo, hasProperty, setProperty, setSourceInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForEachStatement

public ForEachStatement(FormalParameter para,
                        Expression collection,
                        Node body)
Creates a new for statement

Throws:
java.lang.IllegalArgumentException - if body is null

ForEachStatement

public ForEachStatement(FormalParameter para,
                        Expression coll,
                        Node body,
                        SourceInfo si)
Creates a new for statement

Parameters:
body - the body
Throws:
java.lang.IllegalArgumentException - if body is null
Method Detail

addVar

public void addVar(java.lang.String s)

getVars

public java.util.List<java.lang.String> getVars()

getParameter

public FormalParameter getParameter()
Gets the initialization statements


setParameter

public void setParameter(FormalParameter l)
Sets the initialization statements


getCollection

public Expression getCollection()
Gets the condition to evaluate at each loop


setCollection

public void setCollection(Expression e)
Sets the condition to evaluate


getBody

public Node getBody()
Returns the body of this statement


setBody

public void setBody(Node node)
Sets the body of this statement

Throws:
java.lang.IllegalArgumentException - if node is null

addLabel

public void addLabel(java.lang.String label)
Adds a label to this statement

Specified by:
addLabel in interface ContinueTarget
Parameters:
label - the label to add
Throws:
java.lang.IllegalArgumentException - if label is null

hasLabel

public boolean hasLabel(java.lang.String label)
Test whether this statement has the given label

Specified by:
hasLabel in interface ContinueTarget
Returns:
true if this statement has the given label

acceptVisitor

public <T> T acceptVisitor(Visitor<T> visitor)
Allows a visitor to traverse the tree

Specified by:
acceptVisitor in class Node
Parameters:
visitor - the visitor to accept

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object