Class TemplateBlock
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.templateModel.AbstractTemplateElement
-
- net.ssehub.easy.instantiation.core.model.templateModel.TemplateBlock
-
- All Implemented Interfaces:
ILanguageElement,ITemplateElement,ITemplateLangElement
- Direct Known Subclasses:
Def
public class TemplateBlock extends AbstractTemplateElement
Implements a template block.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private ITemplateElement[]body
-
Constructor Summary
Constructors Constructor Description TemplateBlock()Constructor for serialization.TemplateBlock(ITemplateElement[] body)Creates a new block.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IVisitor visitor)Accepts the visitor for visiting.booleanendsWithContentStatement()Returns whether this element ends with a content statement.ITemplateElementgetBodyElement(int index)Get the element of this block at the specified index.intgetBodyElementCount()Get the number of body elements of this rule.protected ITemplateElementgetTypeDefiningElement()Returns the type-defining body element.TypeDescriptor<?>inferType()Infers the type of this language element.booleanisBlock()Returns whether this element is a block (opposite is a single statement).voidsetBody(ITemplateElement[] body)Changes the body elements.protected voidsetParent(ILanguageElement parent)Changes the parent.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.templateModel.AbstractTemplateElement
getParent
-
-
-
-
Field Detail
-
body
private ITemplateElement[] body
-
-
Constructor Detail
-
TemplateBlock
TemplateBlock()
Constructor for serialization.
-
TemplateBlock
public TemplateBlock(ITemplateElement[] body)
Creates a new block.- Parameters:
body- the body
-
-
Method Detail
-
setBody
public void setBody(ITemplateElement[] body)
Changes the body elements.- Parameters:
body- the new body elements
-
getBodyElementCount
public int getBodyElementCount()
Get the number of body elements of this rule.- Returns:
- The number of body elements of this rule.
-
getBodyElement
public ITemplateElement getBodyElement(int index)
Get the element of this block at the specified index.- Parameters:
index- The 0-based index of the element to be returned.- Returns:
- The element at the given index.
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index >=getBodyElementCount()
-
accept
public java.lang.Object accept(IVisitor visitor) throws VilException
Description copied from interface:ITemplateLangElementAccepts the visitor for visiting.- Parameters:
visitor- the visitor to be used- Returns:
- the result of visiting this instance (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
isBlock
public boolean isBlock()
Description copied from interface:ITemplateElementReturns whether this element is a block (opposite is a single statement).- Returns:
trueif it is a block,falseelse
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Description copied from interface:ITemplateElementInfers the type of this language element.- Returns:
- the type of this language element
- Throws:
VilException- in case that type errors occur
-
getTypeDefiningElement
protected ITemplateElement getTypeDefiningElement()
Returns the type-defining body element.- Returns:
- the type-defining body element
-
setParent
protected void setParent(ILanguageElement parent)
Description copied from class:AbstractTemplateElementChanges the parent. Please override if children must be adjusted according. Shall be called only once per instance, but there is no limitation.- Overrides:
setParentin classAbstractTemplateElement- Parameters:
parent- the parent
-
endsWithContentStatement
public boolean endsWithContentStatement()
Description copied from interface:ITemplateElementReturns whether this element ends with a content statement.- Returns:
truefor end with content statement,falseelse
-
-