public class SourceData
extends java.lang.Object
getSource()
. The rough idea is to store the parent ast
node and the index of the child which has to be matched (for convenience reasons
-1 encodes that the parent node itself has to be matched).
This kind of wrapping is useful when matching list schemavariables.Modifier and Type | Field and Description |
---|---|
private int |
childPos
the position of the children of element which has to be matched
against the pattern.
|
private ProgramElement |
element
the program element being either the parent of the program element to be matched or
the element itself depending on the value of childPos
|
private Services |
services
the services
|
Constructor and Description |
---|
SourceData(ProgramElement element,
int childPos,
Services services)
creates a new source data object with parent node element whose
childPos-th child has to be matched (-1 denotes element itself
has to be matched
|
Modifier and Type | Method and Description |
---|---|
int |
getChildPos()
returns index of the child to be matched
|
ProgramElement |
getElement()
returns always the parent node
|
Services |
getServices()
returns the services object
|
ProgramElement |
getSource()
returns the element to be matched, i.e. if @link #getChildPos() is -1
it returns @link #getElement()
otherwise it returns the getChildPos()-th child or null if the returned
child position is out of bound.
|
void |
next()
increments the child position by one, this means moving on to the next sibling
(or the first child if childPos has been -1 before
|
void |
setChildPos(int childPos)
sets the index of the child to be matched
|
void |
setElement(ProgramElement element)
sets the parent node
|
java.lang.String |
toString()
toString
|
private ProgramElement element
private int childPos
private final Services services
public SourceData(ProgramElement element, int childPos, Services services)
element
- the ProgramElementchildPos
- the int giving the index of the child of element to be matchedservices
- the Servicespublic int getChildPos()
public void setChildPos(int childPos)
childPos
- the int with the new indexpublic ProgramElement getElement()
public void setElement(ProgramElement element)
element
- the ProgramElement used as new parent nodepublic ProgramElement getSource()
public void next()
public Services getServices()
public java.lang.String toString()
toString
in class java.lang.Object