RECODER 0.92

recoder.java.statement
Class LoopStatement

java.lang.Object
  extended by recoder.java.JavaSourceElement
      extended by recoder.java.JavaProgramElement
          extended by recoder.java.JavaNonTerminalProgramElement
              extended by recoder.java.statement.JavaStatement
                  extended by recoder.java.statement.LoopStatement
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ExpressionContainer, NonTerminalProgramElement, ProgramElement, SourceElement, Statement, StatementContainer, ModelElement
Direct Known Subclasses:
Do, EnhancedFor, For, While

public abstract class LoopStatement
extends JavaStatement
implements StatementContainer, ExpressionContainer

Loop statement.

Author:
AutoDoc
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface recoder.java.ProgramElement
ProgramElement.TreeStructure
 
Nested classes/interfaces inherited from interface recoder.java.SourceElement
SourceElement.Position
 
Nested classes/interfaces inherited from interface recoder.java.ProgramElement
ProgramElement.TreeStructure
 
Nested classes/interfaces inherited from interface recoder.java.SourceElement
SourceElement.Position
 
Field Summary
 
Fields inherited from class recoder.java.JavaSourceElement
factory
 
Fields inherited from interface recoder.java.ProgramElement
STRUCTURAL_EQUALITY, STRUCTURAL_HASH_CODE
 
Fields inherited from interface recoder.java.ProgramElement
STRUCTURAL_EQUALITY, STRUCTURAL_HASH_CODE
 
Constructor Summary
  LoopStatement()
          Loop statement.
protected LoopStatement(LoopStatement proto)
          Loop statement.
  LoopStatement(Statement body)
          Loop statement.
 
Method Summary
abstract  LoopStatement deepClone()
          Creates a deep clone of the current source element.
 Statement getBody()
          Get body.
 ProgramElement getChildAt(int index)
          Returns the child at the specified index in this node's "virtual" child array
 int getChildCount()
          Returns the number of children of this node.
 int getChildPositionCode(ProgramElement child)
          Returns the positional code of the given child, or -1 if there is no such child.
 Expression getExpressionAt(int index)
           
 int getExpressionCount()
          Get the number of expressions in this container.
 Expression getGuard()
          Get guard.
 ASTList<LoopInitializer> getInitializers()
          Get initializers.
 Statement getStatementAt(int index)
           
 int getStatementCount()
          Get the number of statements in this container.
 ASTList<Expression> getUpdates()
          Get updates.
abstract  boolean isCheckedBeforeIteration()
          Is checked before iteration.
abstract  boolean isExitCondition()
          Is exit condition.
 void makeParentRoleValid()
          Make parent role valid.
 boolean replaceChild(ProgramElement p, ProgramElement q)
          Replace a single child in the current node.
 void setBody(Statement statement)
          Set body.
 void setGuard(Expression expr)
          Set guard.
 void setInitializers(ASTList<LoopInitializer> list)
          Set initializers.
 void setUpdates(ASTList<Expression> list)
          Set updates.
 
Methods inherited from class recoder.java.statement.JavaStatement
getASTParent, getStatementContainer, setStatementContainer
 
Methods inherited from class recoder.java.JavaNonTerminalProgramElement
getIndexOfChild, getRoleOfChild, makeAllParentRolesValid, validateAll
 
Methods inherited from class recoder.java.JavaProgramElement
getComments, getID, setComments, validate
 
Methods inherited from class recoder.java.JavaSourceElement
getEndPosition, getFactory, getFirstElement, getLastElement, getRelativePosition, getStartPosition, setEndPosition, setRelativePosition, setStartPosition, toSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface recoder.java.NonTerminalProgramElement
getIndexOfChild, getRoleOfChild, makeAllParentRolesValid, validateAll
 
Methods inherited from interface recoder.java.ProgramElement
getASTParent, getComments, getID, setComments
 
Methods inherited from interface recoder.java.SourceElement
accept, getEndPosition, getFactory, getFirstElement, getLastElement, getRelativePosition, getStartPosition, setEndPosition, setRelativePosition, setStartPosition, toSource
 
Methods inherited from interface recoder.ModelElement
validate
 
Methods inherited from interface recoder.java.NonTerminalProgramElement
getIndexOfChild, getRoleOfChild, makeAllParentRolesValid, validateAll
 
Methods inherited from interface recoder.java.ProgramElement
getASTParent, getComments, getID, setComments
 
Methods inherited from interface recoder.java.SourceElement
accept, getEndPosition, getFactory, getFirstElement, getLastElement, getRelativePosition, getStartPosition, setEndPosition, setRelativePosition, setStartPosition, toSource
 
Methods inherited from interface recoder.ModelElement
validate
 

Constructor Detail

LoopStatement

public LoopStatement()
Loop statement.


LoopStatement

public LoopStatement(Statement body)
Loop statement.

Parameters:
body - a statement.

LoopStatement

protected LoopStatement(LoopStatement proto)
Loop statement.

Parameters:
proto - a loop statement.
Method Detail

makeParentRoleValid

public void makeParentRoleValid()
Make parent role valid.

Specified by:
makeParentRoleValid in interface NonTerminalProgramElement
Overrides:
makeParentRoleValid in class JavaNonTerminalProgramElement

getChildCount

public int getChildCount()
Returns the number of children of this node.

Specified by:
getChildCount in interface NonTerminalProgramElement
Returns:
an int giving the number of children of this node

getChildAt

public ProgramElement getChildAt(int index)
Returns the child at the specified index in this node's "virtual" child array

Specified by:
getChildAt in interface NonTerminalProgramElement
Parameters:
index - an index into this node's "virtual" child array
Returns:
the program element at the given position
Throws:
java.lang.ArrayIndexOutOfBoundsException - if index is out of bounds

getChildPositionCode

public int getChildPositionCode(ProgramElement child)
Description copied from interface: NonTerminalProgramElement
Returns the positional code of the given child, or -1 if there is no such child. The result contains an encoding of the relative position of the child as well as the role it has been playing in this parent element. This information is required internally for proper undo of transformations and is to be delivered to the detached method of the ChangeHistory.

Specified by:
getChildPositionCode in interface NonTerminalProgramElement
Parameters:
child - the exact child to look for.
Returns:
the positional code of the given child, or -1.
See Also:
ChangeHistory.detached(recoder.java.ProgramElement, recoder.java.NonTerminalProgramElement, int)

replaceChild

public boolean replaceChild(ProgramElement p,
                            ProgramElement q)
Replace a single child in the current node. The child to replace is matched by identity and hence must be known exactly. The replacement element can be null - in that case, the child is effectively removed. The parent role of the new child is validated, while the parent link of the replaced child is left untouched.

Specified by:
replaceChild in interface NonTerminalProgramElement
Parameters:
p - the old child.
p - the new child.
Returns:
true if a replacement has occured, false otherwise.
Throws:
java.lang.ClassCastException - if the new child cannot take over the role of the old one.

getExpressionCount

public int getExpressionCount()
Get the number of expressions in this container.

Specified by:
getExpressionCount in interface ExpressionContainer
Returns:
the number of expressions.

getExpressionAt

public Expression getExpressionAt(int index)
Specified by:
getExpressionAt in interface ExpressionContainer

getGuard

public Expression getGuard()
Get guard.

Returns:
the expression.

setGuard

public void setGuard(Expression expr)
Set guard.

Parameters:
expr - an expression.

getBody

public Statement getBody()
Get body.

Returns:
the statement.

setBody

public void setBody(Statement statement)
Set body.

Parameters:
statement - a statement.

getStatementCount

public int getStatementCount()
Get the number of statements in this container.

Specified by:
getStatementCount in interface StatementContainer
Returns:
the number of statements.

getStatementAt

public Statement getStatementAt(int index)
Specified by:
getStatementAt in interface StatementContainer

getInitializers

public ASTList<LoopInitializer> getInitializers()
Get initializers.

Returns:
the loop initializer mutable list.

getUpdates

public ASTList<Expression> getUpdates()
Get updates.

Returns:
the expression mutable list.

isExitCondition

public abstract boolean isExitCondition()
Is exit condition.

Returns:
the boolean value.

isCheckedBeforeIteration

public abstract boolean isCheckedBeforeIteration()
Is checked before iteration.

Returns:
the boolean value.

setInitializers

public void setInitializers(ASTList<LoopInitializer> list)
Set initializers.

Parameters:
list - a loop initializer mutable list.

setUpdates

public void setUpdates(ASTList<Expression> list)
Set updates.

Parameters:
list - an expression mutable list.

deepClone

public abstract LoopStatement deepClone()
Description copied from interface: SourceElement
Creates a deep clone of the current source element. For NonTerminalProgramElements, the parent roles are valid, except that the root element is not included anywhere and hence has no set parents, of course. This method also clones Comment s, but does not clone derived information such as scopes.

Specified by:
deepClone in interface SourceElement
Specified by:
deepClone in interface Statement

RECODER 0.92