uk.ac.bbk.dcs.automed.xml.sra.old.xmldssGraph
Class XMLDSSGraph

java.lang.Object
  extended by uk.ac.bbk.dcs.automed.xml.sra.old.xmldssGraph.XMLDSSGraph

public class XMLDSSGraph
extends java.lang.Object

Class Task Description

Author:
Lucas Zamboulis

Field Summary
private  java.util.LinkedList elements
           
private  XMLDSSGraphElement entryPoint
           
 
Constructor Summary
XMLDSSGraph(org.w3c.dom.Document domDoc)
           
 
Method Summary
private  void addAttributes(org.w3c.dom.Node n, XMLDSSGraphElement xge)
           
 void addElement(XMLDSSGraphElement xge, XMLDSSGraphElement parent)
           
private  void addText(org.w3c.dom.Node n, XMLDSSGraphElement xge)
           
 void drawTree()
           
 int findPath(XMLDSSGraphElement supposedChild, XMLDSSGraphElement supposedParent, java.util.LinkedList goingUpPath, java.util.LinkedList goingDownPath)
          IMPORTANT: Both goingUpPath and goingDownPath lists contain the common ancestor.
 XMLDSSGraphElement getElement(java.lang.String name)
           
private static int getElementDepth(XMLDSSGraphElement n)
          Returns the depth of node n.
 java.util.LinkedList getElements()
           
 XMLDSSGraphElement getEntryPoint()
           
 boolean isTree()
           
 void printGraphNodes(java.io.PrintStream ps)
           
 void printTree(java.io.PrintStream ps)
           
private  void printTreeNode(java.lang.Object o, int indent, java.io.PrintStream ps)
           
 void setEntryPoint(XMLDSSGraphElement entryPoint)
           
private  void treatChildren(org.w3c.dom.Node n, XMLDSSGraphElement xge)
           
private  void treatElement(org.w3c.dom.Node n, XMLDSSGraphElement parent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entryPoint

private XMLDSSGraphElement entryPoint

elements

private java.util.LinkedList elements
Constructor Detail

XMLDSSGraph

public XMLDSSGraph(org.w3c.dom.Document domDoc)
            throws XMLDSSGraphException
Throws:
XMLDSSGraphException
Method Detail

treatChildren

private void treatChildren(org.w3c.dom.Node n,
                           XMLDSSGraphElement xge)
                    throws XMLDSSGraphException
Throws:
XMLDSSGraphException

treatElement

private void treatElement(org.w3c.dom.Node n,
                          XMLDSSGraphElement parent)
                   throws XMLDSSGraphException
Throws:
XMLDSSGraphException

addElement

public void addElement(XMLDSSGraphElement xge,
                       XMLDSSGraphElement parent)

addAttributes

private void addAttributes(org.w3c.dom.Node n,
                           XMLDSSGraphElement xge)

addText

private void addText(org.w3c.dom.Node n,
                     XMLDSSGraphElement xge)

getElements

public java.util.LinkedList getElements()

getElement

public XMLDSSGraphElement getElement(java.lang.String name)

getEntryPoint

public XMLDSSGraphElement getEntryPoint()

setEntryPoint

public void setEntryPoint(XMLDSSGraphElement entryPoint)
                   throws XMLDSSGraphException
Throws:
XMLDSSGraphException

isTree

public boolean isTree()

printTree

public void printTree(java.io.PrintStream ps)
               throws XMLDSSGraphException
Throws:
XMLDSSGraphException

printTreeNode

private void printTreeNode(java.lang.Object o,
                           int indent,
                           java.io.PrintStream ps)
                    throws XMLDSSGraphException
Throws:
XMLDSSGraphException

drawTree

public void drawTree()

printGraphNodes

public void printGraphNodes(java.io.PrintStream ps)
                     throws XMLDSSGraphException
Throws:
XMLDSSGraphException

findPath

public int findPath(XMLDSSGraphElement supposedChild,
                    XMLDSSGraphElement supposedParent,
                    java.util.LinkedList goingUpPath,
                    java.util.LinkedList goingDownPath)
IMPORTANT: Both goingUpPath and goingDownPath lists contain the common ancestor. It is up to the function using the result of this method to remove the duplicate common ancestor coming from one of these two lists.

Parameters:
supposedChild - the node from where the path begins
supposedParent - the node the path ends at
goingUpPath - a LinkedList object containing the nodes from supposedChild to supposedParent, if indeed supposedChild is in the same branch with supposed parent and is deeper than supposedParent. In this case, it is returned full. As the name suggests, this list represents going up the schema.
goingDownPath - a LinkedList object containing the nodes from common ancestor to supposedParent or from supposedChild to supposedParent, if they are in the same branch and supposedParent is deeper than supposedChild. supposedParent is always the last node in the list. As the name suggests, this list represents going up the schema.
Returns:
an integer in [1,5]:
- 1 means the two nodes are in the same branch and toNode is higher than fromNode
- 2 means the two nodes are in the same branch and toNode is lower than fromNode
- 3 means the two nodes are in different branches and toNode is higher than fromNode
- 4 means the two nodes are in different branches and toNode is lower than fromNode
- 5 means the two nodes are in different branches and toNode is in the same height as fromNode

getElementDepth

private static int getElementDepth(XMLDSSGraphElement n)
Returns the depth of node n. If n is the root, its depth is 0, etc.