openjava.ptree
Class ForStatement

java.lang.Object
  |
  +--openjava.ptree.ParseTreeObject
        |
        +--openjava.ptree.NonLeaf
              |
              +--openjava.ptree.ForStatement
All Implemented Interfaces:
Cloneable, ParseTree, Statement

public class ForStatement
extends NonLeaf
implements Statement, ParseTree

The ForStatement class represents a for statement node of parse tree.
The specification of the initialization part may be modified in the later version of OpenJava.

See Also:
ParseTree, NonLeaf, Statement, Expression, ExpressionList, StatementList

Field Summary
 
Fields inherited from class openjava.ptree.NonLeaf
 
Fields inherited from class openjava.ptree.ParseTreeObject
debugFlag, debugLevel, LN, out, writerStack
 
Constructor Summary
(package private) ForStatement()
          Allocates a new ForStatement object.
  ForStatement(ExpressionList init, Expression expr, ExpressionList iterator, StatementList stmts)
          Allocates a new ForStatement object.
  ForStatement(String varName, Expression query, StatementList stmts)
          Allocates a new ForStatement object of the form for (variable in query) ….
  ForStatement(TypeName tspec, VariableDeclarator[] vdecls, Expression expr, ExpressionList iterator, StatementList stmts)
           
 
Method Summary
 void accept(ParseTreeVisitor v)
          Accepts a ParseTreeVisitor object as the role of a Visitor in the Visitor pattern, as the role of an Element in the Visitor pattern.
 Expression getCondition()
          Gets the condition part of this for-statement.
 ExpressionList getIncrement()
          Gets the increments part of this for-statement.
 ExpressionList getInit()
          Gets the initialization part of this for-statement.
 VariableDeclarator[] getInitDecls()
          Gets the initialization part of this for-statement.
 TypeName getInitDeclType()
          Gets the initialization part of this for-statement.
 Expression getQuery()
          Gets the 'in' expression of this for-statement.
 StatementList getStatements()
          Gets the body of this for-statement.
 String getVariable()
          Gets the name of the 'in' variable in a for-statement.
 void setCondition(Expression cond)
          Sets the condition part of this for-statement.
 void setIncrement(ExpressionList incs)
          Sets the increments part of this for-statement.
 void setInit(ExpressionList init)
          Sets the initialization part of this for-statement.
 void setInitDecl(TypeName type_specifier, VariableDeclarator[] init)
          Sets the initialization part of this for-statement.
 void setQuery(Expression query)
          Sets the 'in' expression of this for-statement.
 void setStatements(StatementList stmts)
          Sets the body of this for-statement.
 void setVariable(String name)
          Sets the name of the 'in' variable of this for-statement.
 void writeCode()
          Writes the code this parse-tree presents for.
 
Methods inherited from class openjava.ptree.NonLeaf
childrenAccept, childrenAreEqual, elementAt, equals, getComment, getContents, getLength, getRowType, makeRecursiveCopy, replaceChildWith, set, set, set, set, set, set, set, set, set, setComment, setElementAt
 
Methods inherited from class openjava.ptree.ParseTreeObject
clone, eq, eq, equal, flushPrintWriter, getDebugFlag, getNest, getObjectID, getParent, getPrintWriter, getTab, hashCode, lastObjectID, makeCopy, popNest, popPrintWriter, pushNest, pushPrintWriter, replace, setDebugFlag, setDebugLevel, setNest, setParent, setPrintStream, setTab, toFlattenString, toString, writeDebug, writeDebugL, writeDebugLln, writeDebugln, writeDebugLR, writeDebugR, writeDebugRln, writeTab
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface openjava.ptree.ParseTree
childrenAccept, eq, equals, getObjectID, makeCopy, makeRecursiveCopy, replace, toFlattenString, toString
 

Constructor Detail

ForStatement

ForStatement()
Allocates a new ForStatement object.


ForStatement

public ForStatement(ExpressionList init,
                    Expression expr,
                    ExpressionList iterator,
                    StatementList stmts)
Allocates a new ForStatement object.

Parameters:
init - the initialization part.
expr - the condition part.
iterator - the increments part.
stmts - the stement list of the body.

ForStatement

public ForStatement(TypeName tspec,
                    VariableDeclarator[] vdecls,
                    Expression expr,
                    ExpressionList iterator,
                    StatementList stmts)

ForStatement

public ForStatement(String varName,
                    Expression query,
                    StatementList stmts)
Allocates a new ForStatement object of the form for (variable in query) ….

Parameters:
varName - name of variable
query - query expression
stmts - the statement list of the body
Method Detail

writeCode

public void writeCode()
Description copied from class: NonLeaf
Writes the code this parse-tree presents for.

Specified by:
writeCode in interface ParseTree
Overrides:
writeCode in class NonLeaf

getInit

public ExpressionList getInit()
Gets the initialization part of this for-statement.

Returns:
the initialization part.

setInit

public void setInit(ExpressionList init)
Sets the initialization part of this for-statement.

Parameters:
init - the initialization part.

getInitDeclType

public TypeName getInitDeclType()
Gets the initialization part of this for-statement.

Returns:
the initialization part.

getInitDecls

public VariableDeclarator[] getInitDecls()
Gets the initialization part of this for-statement.

Returns:
the initialization part.

setInitDecl

public void setInitDecl(TypeName type_specifier,
                        VariableDeclarator[] init)
Sets the initialization part of this for-statement.

Parameters:
init - the initialization part.

getCondition

public Expression getCondition()
Gets the condition part of this for-statement.

Returns:
the expression of the condtion part.

setCondition

public void setCondition(Expression cond)
Sets the condition part of this for-statement.

Parameters:
cond - the expression of the condtion part.

getIncrement

public ExpressionList getIncrement()
Gets the increments part of this for-statement.

Returns:
the expression list of the increments part.

setIncrement

public void setIncrement(ExpressionList incs)
Sets the increments part of this for-statement.

Parameters:
incs - the expression list of the increments part.

getStatements

public StatementList getStatements()
Gets the body of this for-statement.

Returns:
the statement list of the body.

setStatements

public void setStatements(StatementList stmts)
Sets the body of this for-statement.

Parameters:
stmts - the statement list of the body.

getVariable

public String getVariable()
Gets the name of the 'in' variable in a for-statement.

Returns:
the name of the variable.

setVariable

public void setVariable(String name)
Sets the name of the 'in' variable of this for-statement.


getQuery

public Expression getQuery()
Gets the 'in' expression of this for-statement.

Returns:
the 'in' expression.

setQuery

public void setQuery(Expression query)
Sets the 'in' expression of this for-statement.

Parameters:
query - the 'in' expression.

accept

public void accept(ParseTreeVisitor v)
            throws ParseTreeException
Description copied from interface: ParseTree
Accepts a ParseTreeVisitor object as the role of a Visitor in the Visitor pattern, as the role of an Element in the Visitor pattern.

This invoke an appropriate visit() method on the accepted visitor.

Specified by:
accept in interface ParseTree
Specified by:
accept in class ParseTreeObject
Parameters:
v - a visitor
ParseTreeException

SourceForge.net_Logo