public class TreeAutomaton
extends java.lang.Object
This special kind of bottom-up tree automaton operates on a tree it is monitoring.
It does not only annotate a static tree to determine whether it matches the encoded pattern,
but is also able to adapt to changes to the tree without recalculating everything,
if the component controlling changes in the tree structure (usually a subclass of KahinaTreeBehavior
) announces the changes.
A tree automaton is usually compiled from a KahinaBreakpoint
, which contains
If the associated breakpoint is active, the automaton will dispatch a KahinaTreeMatchEvent
to its KahinaController
as soon as the encoded pattern is found in the tree it monitors.
Constructor and Description |
---|
TreeAutomaton(KahinaBreakpoint bp)
Class constructor specifying the breakpoint to be associated with the new automaton.
|
Modifier and Type | Method and Description |
---|---|
void |
addAcceptingState(int state) |
void |
addRule(TreeAutomatonRule rule) |
void |
addState(int state) |
boolean |
annotate(int nodeID,
int stateID)
Annotates a single node in the tree with some state ID and checks whether this resulted in a change.
|
java.util.Set<java.lang.Integer> |
getAnnotations(int nodeID)
Retrieves the current annotations for a single tree node.
|
java.util.Set<java.lang.Integer> |
getChildAnnotations(int nodeID)
Retrieves the current annotations for all the children of a single tree node.
|
KahinaInstance<?,?,?,?> |
getKahina() |
int |
nextStateNumber() |
void |
process(int nodeID)
Annotates a tree node with all possible labels according to the rules and
recursively reannotates parents if it triggers a change in annotation.
|
void |
setConstellationMatch(boolean constellationMatch)
Determine whether the automaton reports matches directly above new nodes twice.
|
void |
setKahina(KahinaInstance<?,?,?,?> kahina)
Sets the Kahina instance this automaton is to inform about matches.
|
void |
setTree(KahinaTree tree)
Sets or changes the tree this automaton is monitoring.
|
java.lang.String |
toString() |
public TreeAutomaton(KahinaBreakpoint bp)
KahinaBreakpoint
when compiled.bp
- the breakpoint object to be associated with the new automatonpublic void setTree(KahinaTree tree)
tree
- the tree model to be monitored by this automatonpublic void setConstellationMatch(boolean constellationMatch)
false
, which is suitable in most contexts.constellationMatch
- true
for extra reports, false
to suppress thempublic KahinaInstance<?,?,?,?> getKahina()
public void setKahina(KahinaInstance<?,?,?,?> kahina)
null
, an instance must be determined for the breakpoint system to work.kahina
- the Kahina instance this automaton is to inform about matchespublic void process(int nodeID)
nodeID
- the node to be (re)annotated by the automatonpublic boolean annotate(int nodeID, int stateID)
nodeID
- the node to be annotatedstateID
- the state ID the node is to be annotated withpublic java.util.Set<java.lang.Integer> getAnnotations(int nodeID)
nodeID
- addresses the node whose annotations we want to getpublic java.util.Set<java.lang.Integer> getChildAnnotations(int nodeID)
nodeID
- addresses the node whose children's annotations we want to getpublic int nextStateNumber()
public void addState(int state)
public void addAcceptingState(int state)
public void addRule(TreeAutomatonRule rule)
public java.lang.String toString()
toString
in class java.lang.Object