public class Block extends Statement implements Statement.Labeled
This class represents a group of Statement
objects. The
statements are stored on this object in the order in which they are added.
Statement.Labeled
LanguageObject.Util
TYPE_ASSIGNMENT, TYPE_BREAK, TYPE_COMMAND, TYPE_COMPOUND, TYPE_CONTINUE, TYPE_DECLARE, TYPE_ERROR, TYPE_IF, TYPE_LEAVE, TYPE_LOOP, TYPE_RETURN, TYPE_UNKNOWN, TYPE_UPDATE, TYPE_WHILE
Constructor and Description |
---|
Block()
Constructor for Block.
|
Block(Statement statement)
Constructor for Block with a single
Statement . |
Modifier and Type | Method and Description |
---|---|
void |
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.
|
void |
addStatement(Statement statement)
Add a
Statement to this block. |
void |
addStatement(Statement statement,
boolean exception) |
Block |
clone()
Deep clone statement to produce a new identical block.
|
boolean |
equals(Object obj)
Compare two queries for equality.
|
String |
getExceptionGroup() |
List<Statement> |
getExceptionStatements() |
String |
getLabel() |
List<Statement> |
getStatements()
Get all the statements contained on this block.
|
int |
getType()
Return type of statement to make it easier to build switch statements by statement type.
|
int |
hashCode()
Get hashcode for block.
|
boolean |
isAtomic() |
void |
setAtomic(boolean atomic) |
void |
setExceptionGroup(String exceptionGroup) |
void |
setExceptionStatements(List<Statement> exceptionStatements) |
void |
setLabel(String label) |
void |
setStatements(List<Statement> statements)
Set the statements contained on this block.
|
String |
toString()
Returns a string representation of an instance of this class.
|
public Block()
public Block(Statement statement)
Statement
.statement
- The Statement
to be added to the blockpublic String getLabel()
getLabel
in interface Statement.Labeled
public void setLabel(String label)
setLabel
in interface Statement.Labeled
public List<Statement> getStatements()
Statement
s contained in this blockpublic void setStatements(List<Statement> statements)
statements
- A list of Statement
s contained in this blockpublic void addStatement(Statement statement)
Statement
to this block.statement
- The Statement
to be added to the blockpublic void addStatement(Statement statement, boolean exception)
public void acceptVisitor(LanguageVisitor visitor)
LanguageObject
acceptVisitor
in interface LanguageObject
visitor
- Visitor being usedpublic Block clone()
clone
in interface LanguageObject
clone
in class Statement
public boolean equals(Object obj)
public int hashCode()
public String toString()
public boolean isAtomic()
public void setAtomic(boolean atomic)
public int getType()
Statement
public String getExceptionGroup()
public void setExceptionGroup(String exceptionGroup)
Copyright © 2019. All rights reserved.