|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectname.angoca.db2sa.core.graph.model.Graph
public class Graph
This class models the graph that represents the read grammar. The construction of the graph is done in two phases: add nodes, and associate node.
The first phase only permits to add nodes to the graph. This is done with the method addNode. Try to establish a relation between nodes is not permitted in this phase.
The second phase permits to establish relation between nodes, once they have been defined. In this phase is not possible to add more nodes.
In order to change the phase, the method 'firstPhaseFinished' has to be called. Once this method is called, is not possible to go back.
The method 'secondPhaseFinished' before to return the StartingNode, it checks the graph if it is stable and there are not inconsistencies. Also, at this phase, the extra nodes are added. The extra nodes include the help node and the about node.
This object is immutable, once it is created, their properties cannot be changed. This is the reason because there are not setter methods. The getters methods are for tests purposes and have a default visibility.
Control Version
Constructor Summary | |
---|---|
Graph(String graphName,
boolean addExtraNodes)
Creates a graph with a given name. |
Method Summary | |
---|---|
void |
addNode(String nodeId,
String nodeName,
boolean reserved)
Adds a new node in the graph. |
void |
addRelation(String parentId,
String childId)
Adds a relation between two nodes, giving the members of the relation, the parent and the child. |
void |
checkDuplicates()
Checks the graph searching nodes that represents the same word for a common parent. |
boolean |
equals(Object obj)
|
void |
firstPhaseFinished()
This parameter change the state of the graph. |
String |
getName()
Returns the name of the graph. |
StartingNode |
getStartingNode()
Returns the StartingNode. |
int |
hashCode()
|
void |
merge(Graph graph)
Merge the current graph in the given graph. |
StartingNode |
secondPhaseFinished()
Process the graph. |
void |
simplifyGraph()
Simplify the graph, by merging nodes that represents the same tokens. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Graph(String graphName, boolean addExtraNodes) throws ParameterNullException
graphName
- Name of this graph.addExtraNodes
- Determines if the graph has to include some extra predefined
nodes.
ParameterNullException
- If the graph name is not given.Method Detail |
---|
public void addNode(String nodeId, String nodeName, boolean reserved) throws AbstractGraphException
nodeId
- Id of the node.nodeName
- Name of the node.reserved
- if the node represents a reserved word.
AbstractGraphException
- If the graph state is invalid, or if the graph name is
invalid, or if the node id already exists in the graph.public void addRelation(String parentId, String childId) throws AbstractDB2SAException
parentId
- Id of the parent node.childId
- Id of the child node.
AbstractDB2SAException
- if the parent or the child do not exist in the set of nodes.
Or if the state of the graph is invalid. Or when trying to
make an invalid relation between two nodes. If a parameter is
null.public boolean equals(Object obj)
equals
in class Object
public void firstPhaseFinished() throws AbstractDB2SAException
AbstractDB2SAException
- If there is a problem adding the extra associations.public String getName()
public StartingNode getStartingNode() throws InvalidGraphStateException
InvalidGraphStateException
- If the graph is in an invalid state to call this method.public int hashCode()
hashCode
in class Object
public void merge(Graph graph) throws AbstractDB2SAException
Both graphs (this and the given one) has to be validated.
The given graph can't be the same.
graph
- Graph that will have all the information of the current graph.
AbstractDB2SAException
- If there is a problem making the fusion between nodes.public StartingNode secondPhaseFinished() throws AbstractDB2SAException
Checks that there is not nodes that references to StartingNode. Also, that EndingNode does not reference any node.
AbstractDB2SAException
- When a node is detected that references the StartingNode. Or
when a node is detected that if referenced by the EndingNode.
Or if a node does not come from StartingNode. Or if a node
does not go to EndingNode. Or if the first phase has not
finished. Or if the graph is in an invalid state.public void checkDuplicates() throws DuplicatedNodeNameException
DuplicatedNodeNameException
- If a double node is found.public void simplifyGraph() throws AbstractDB2SAException
AbstractDB2SAException
- If there is a problem add when merging the nodes.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |