|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.teatrove.tea.parsetree.Node
org.teatrove.tea.parsetree.Statement
org.teatrove.tea.parsetree.ForeachStatement
public class ForeachStatement
A ForeachStatement iterates over the values of an array or a Collection, storing each value in a variable, allowing a statement or statements to operate on each. Reverse looping is supported for arrays and Lists.
Because Collections don't know the type of elements they contain (they only know that they are Objects), the only operations allowed on the loop variable are those that are defined for Object.
Collection class can be subclassed to contain a special field that defines the element type. The field must have the following signature: public static final Class ELEMENT_TYPE
| Constructor Summary | |
|---|---|
ForeachStatement(SourceInfo info,
VariableRef loopVar,
Expression range,
Expression endRange,
boolean reverse,
Block body)
|
|
| Method Summary | |
|---|---|
Object |
accept(NodeVisitor visitor)
Every subclass of Node must override this method with the following: return visitor.visit(this). |
Object |
clone()
Returns a clone of this Node and all its children. |
Block |
getBody()
|
Expression |
getEndRange()
Returns null if this foreach statement iterates over an array/collection instead of an integer range of values. |
Statement |
getInitializer()
Initializer is a section of code that executes before the loop is entered. |
VariableRef |
getLoopVariable()
|
Expression |
getRange()
|
boolean |
isReverse()
|
void |
setBody(Block body)
|
void |
setEndRange(Expression endRange)
|
void |
setInitializer(Statement stmt)
|
void |
setRange(Expression range)
|
| Methods inherited from class org.teatrove.tea.parsetree.Statement |
|---|
isBreak, isReturn |
| Methods inherited from class org.teatrove.tea.parsetree.Node |
|---|
getSourceInfo, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ForeachStatement(SourceInfo info,
VariableRef loopVar,
Expression range,
Expression endRange,
boolean reverse,
Block body)
| Method Detail |
|---|
public Object accept(NodeVisitor visitor)
Nodereturn visitor.visit(this).
accept in class Statementvisitor - A visitor of this Node
NodeVisitorpublic Object clone()
Node
clone in class Nodepublic VariableRef getLoopVariable()
public Expression getRange()
public Expression getEndRange()
public boolean isReverse()
public Statement getInitializer()
public Block getBody()
public void setRange(Expression range)
public void setEndRange(Expression endRange)
public void setInitializer(Statement stmt)
public void setBody(Block body)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||