agg.parser
Class AbstractParser

java.lang.Object
  extended by agg.parser.AbstractParser
All Implemented Interfaces:
Parser
Direct Known Subclasses:
ExcludeParser, SimpleParser

public abstract class AbstractParser
extends java.lang.Object
implements Parser

This parser eats graphs which are created by AGG. A parser needs a host graph and a stop graph. The graph grammar for parsing must contain reducing rules. This abstract parser provides some convenient methods for parsing.


Field Summary
protected  int delay
           
protected  GraGra grammar
          The grammar which can recognize a graph
protected  Graph graph
          The Graph which will be parsed
protected  java.util.Vector<ParserEventListener> listener
          All listerner which want to receive events
protected  PairContainer pairContainer
          The set of critical pairs
protected  Graph stopGraph
          The graph which stops the algorithm
 
Constructor Summary
AbstractParser(GraGra grammar, Graph hostGraph, Graph stopGraph, PairContainer pairContainer)
          Creates a new abstract parser.
 
Method Summary
 void addParserEventListener(ParserEventListener l)
          Adds a ParserEventListener.
protected  boolean applyRule(Match m)
          Applys a rule on a host graph.
protected  void finalize()
          Clears some internal stuff.
protected  Match findMatch(Graph g, java.util.Enumeration<?> rules, RuleInstances eri)
          Finds a valid match for a set of rules.
protected  Match findMatch(Graph g, java.util.Enumeration<Rule> rules)
          Finds a valid match for a set of rules.
protected  void fireParserEvent(ParserEvent event)
          Sends a event to all its listeners.
 Graph getGraph()
          Returns the host graph from the parser.
 Graph getHostGraph()
          Returns the host graph from the parser.
 Graph getStopGraph()
          Returns the current stop graph of the parser.
abstract  boolean parse()
          Starts the parser.
 void parseString()
          Parse the methods and attributes of an UML-Diagram.
protected  void printGraph(Graph g)
           
protected  void printImageGraph(Morphism m)
           
 void removeParserEventListener(ParserEventListener l)
          Removes a ParserEventListener
 void setCriticalPairs(PairContainer pairs)
          Sets the critical pairs for the parser.
 void setDelayAfterApplyRule(int miliseconds)
           
 void setGrammar(GraGra grammar)
          Sets the grammar for the parser.
 void setHostGraph(Graph hostGraph)
          Sets the host graph for the parser.
 void setStopGraph(Graph stopGraph)
          Sets the stop graph for the parser.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grammar

protected GraGra grammar
The grammar which can recognize a graph


graph

protected Graph graph
The Graph which will be parsed


stopGraph

protected Graph stopGraph
The graph which stops the algorithm


pairContainer

protected PairContainer pairContainer
The set of critical pairs


listener

protected java.util.Vector<ParserEventListener> listener
All listerner which want to receive events


delay

protected int delay
Constructor Detail

AbstractParser

public AbstractParser(GraGra grammar,
                      Graph hostGraph,
                      Graph stopGraph,
                      PairContainer pairContainer)
Creates a new abstract parser. This parser stores all the basic information like host graph, stop graph, critical pairs and graph grammar.

Parameters:
grammar - The graph grammar.
hostGraph - The host graph.
stopGraph - The stop graph.
pairContainer - The container of the critical pairs.
Method Detail

setHostGraph

public void setHostGraph(Graph hostGraph)
Sets the host graph for the parser.

Specified by:
setHostGraph in interface Parser
Parameters:
hostGraph - The host graph.

setStopGraph

public void setStopGraph(Graph stopGraph)
Sets the stop graph for the parser.

Specified by:
setStopGraph in interface Parser
Parameters:
stopGraph - The stop graph.

setCriticalPairs

public void setCriticalPairs(PairContainer pairs)
Sets the critical pairs for the parser.

Specified by:
setCriticalPairs in interface Parser
Parameters:
pairs - The critical pairs are holded in a container.

setGrammar

public void setGrammar(GraGra grammar)
Sets the grammar for the parser. This grammar must contain reducing rules.

Specified by:
setGrammar in interface Parser
Parameters:
grammar - The grammar for the parser.

getHostGraph

public Graph getHostGraph()
Returns the host graph from the parser. This method is important to get the current state of parsing process.

Specified by:
getHostGraph in interface Parser
Returns:
The current host graph.

getGraph

public Graph getGraph()
Returns the host graph from the parser. This method is important to get the current state of parsing process.

Specified by:
getGraph in interface Parser
Returns:
The current host graph.

getStopGraph

public Graph getStopGraph()
Returns the current stop graph of the parser.

Specified by:
getStopGraph in interface Parser
Returns:
The stop graph.

parse

public abstract boolean parse()
Starts the parser. The result is true if the parser can parse the graph

Specified by:
parse in interface Parser
Returns:
true if the graph can be parsed.

applyRule

protected boolean applyRule(Match m)
Applys a rule on a host graph. As the match provides access as well as to the rule of the match as to the host graph.

Parameters:
m - The match.

findMatch

protected Match findMatch(Graph g,
                          java.util.Enumeration<?> rules,
                          RuleInstances eri)
Finds a valid match for a set of rules. Additionally there is a check on RuleInstances.

Parameters:
g - The graph to match into. Usually the host graph.
rules - This enumeration must contain rule objects.
eri - The rule instances.
Returns:
The valid match from a choosen rule into the graph.

findMatch

protected Match findMatch(Graph g,
                          java.util.Enumeration<Rule> rules)
Finds a valid match for a set of rules.

Parameters:
g - The graph to match into. Usually the host graph.
rules - This enumeration must contain rule objects.
Returns:
A valid match from a choosen rule into the graph.
See Also:
findMatch(Graph g, Enumeration rules, RuleInstances eri)

finalize

protected void finalize()
Clears some internal stuff.

Overrides:
finalize in class java.lang.Object

parseString

public void parseString()
Parse the methods and attributes of an UML-Diagram.


addParserEventListener

public void addParserEventListener(ParserEventListener l)
Adds a ParserEventListener.

Specified by:
addParserEventListener in interface Parser
Parameters:
l - The listener.

removeParserEventListener

public void removeParserEventListener(ParserEventListener l)
Removes a ParserEventListener

Specified by:
removeParserEventListener in interface Parser
Parameters:
l - The listener.

fireParserEvent

protected void fireParserEvent(ParserEvent event)
Sends a event to all its listeners.

Parameters:
event - The event which will be sent

printImageGraph

protected void printImageGraph(Morphism m)

printGraph

protected void printGraph(Graph g)

setDelayAfterApplyRule

public void setDelayAfterApplyRule(int miliseconds)
Specified by:
setDelayAfterApplyRule in interface Parser