de.uka.algo.GT3D
Class GT3DGraphMLFileHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by edu.uci.ics.jung.io.GraphMLFileHandler
          extended by de.uka.algo.GT3D.GT3DGraphMLFileHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class GT3DGraphMLFileHandler
extends edu.uci.ics.jung.io.GraphMLFileHandler

A GraphML file handler to parse simple GraphML files

Author:
stm

Field Summary
(package private)  edu.uci.ics.jung.graph.Edge currentEdge
          The edge represented by the currently open edge tag or null.
(package private)  java.lang.String currentKey
          The node represented by the currently open data tag or null.
(package private)  edu.uci.ics.jung.graph.Vertex currentVertex
          The node represented by the currently open edge tag or null.
(package private)  java.util.Map<java.lang.String,java.lang.String> keyMap
          A map from keys (of data tags) to the corresponding names.
private  edu.uci.ics.jung.graph.Graph mGraph
          The graph we are reading.
private  edu.uci.ics.jung.graph.decorators.StringLabeller mLabeller
          Stores the node and edge labels that can be retrieved by its getUserData method.
 
Constructor Summary
GT3DGraphMLFileHandler()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          This method is called whenever the SaX parser encounters character content inside a tag
protected  void createGraph(java.util.Map attributeMap)
          creates a new graph
protected  void endData()
          Called if a data tag is closed.
protected  void endEdge()
          Called when a edge tag is closed.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          This method is called whenever the SaX parser encounters a closing tag
protected  void endVertex()
          Called when a vertex tag is closed.
private  java.util.Map<java.lang.String,java.lang.String> getAttributeMap(org.xml.sax.Attributes attrs)
           
protected  edu.uci.ics.jung.graph.Graph getGraph()
           
protected  edu.uci.ics.jung.graph.decorators.StringLabeller getLabeller()
           
protected  void insertKey(java.util.Map<java.lang.String,java.lang.String> attributeMap)
          Inserts a new (key, value)-pair into keyMap.
protected  void startData(java.util.Map attributeMap)
          Called if a data tag is found.
protected  edu.uci.ics.jung.graph.Edge startEdge(java.util.Map attributeMap)
          Initialize a new edge and insert it into the graph.
 void startElement(java.lang.String lName, java.lang.String namespaceURI, java.lang.String qName, org.xml.sax.Attributes attrs)
          This method is called whenever the SaX parser encounters an opening tag
protected  edu.uci.ics.jung.graph.Vertex startVertex(java.util.Map attributeMap)
          Initialize a new vertex and insert it into the graph.
 
Methods inherited from class edu.uci.ics.jung.io.GraphMLFileHandler
createEdge, createVertex
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mGraph

private edu.uci.ics.jung.graph.Graph mGraph
The graph we are reading.


mLabeller

private edu.uci.ics.jung.graph.decorators.StringLabeller mLabeller
Stores the node and edge labels that can be retrieved by its getUserData method.


currentEdge

edu.uci.ics.jung.graph.Edge currentEdge
The edge represented by the currently open edge tag or null.


currentVertex

edu.uci.ics.jung.graph.Vertex currentVertex
The node represented by the currently open edge tag or null.


currentKey

java.lang.String currentKey
The node represented by the currently open data tag or null.


keyMap

java.util.Map<java.lang.String,java.lang.String> keyMap
A map from keys (of data tags) to the corresponding names.

Constructor Detail

GT3DGraphMLFileHandler

public GT3DGraphMLFileHandler()
Method Detail

getGraph

protected edu.uci.ics.jung.graph.Graph getGraph()
Overrides:
getGraph in class edu.uci.ics.jung.io.GraphMLFileHandler

getLabeller

protected edu.uci.ics.jung.graph.decorators.StringLabeller getLabeller()
Overrides:
getLabeller in class edu.uci.ics.jung.io.GraphMLFileHandler

getAttributeMap

private java.util.Map<java.lang.String,java.lang.String> getAttributeMap(org.xml.sax.Attributes attrs)

createGraph

protected void createGraph(java.util.Map attributeMap)
creates a new graph

Overrides:
createGraph in class edu.uci.ics.jung.io.GraphMLFileHandler
Parameters:
attributeMap - the attributes of the graph tag.
See Also:
GraphMLFileHandler.createGraph(java.util.Map)

startVertex

protected edu.uci.ics.jung.graph.Vertex startVertex(java.util.Map attributeMap)
Initialize a new vertex and insert it into the graph. This method is called if a node tag is opened. A node is identified by its id tag and may contain data tags.

Parameters:
attributeMap - the attributes of the node tag.
Returns:
The newly created vertex.

startEdge

protected edu.uci.ics.jung.graph.Edge startEdge(java.util.Map attributeMap)
Initialize a new edge and insert it into the graph. This method is called if an edge tag is opened. An edge is identified by its id tag and may contain data tags.

Parameters:
attributeMap - the attributes of the edge tag.
Returns:
the newly created edge.

endVertex

protected void endVertex()
Called when a vertex tag is closed.


endEdge

protected void endEdge()
Called when a edge tag is closed.


insertKey

protected void insertKey(java.util.Map<java.lang.String,java.lang.String> attributeMap)
Inserts a new (key, value)-pair into keyMap. Called when a key tag is opened. A key tag has the attributes id and for and additional attr.type and attr.name attributes.

Parameters:
attributeMap - The attributes of the key tag

startData

protected void startData(java.util.Map attributeMap)
Called if a data tag is found. This tag is identified by a key attribute which is specified in a key entry and contains the edge or node label as content.

Parameters:
attributeMap - The attributes of the tag.

endData

protected void endData()
Called if a data tag is closed.


startElement

public void startElement(java.lang.String lName,
                         java.lang.String namespaceURI,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
This method is called whenever the SaX parser encounters an opening tag

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class edu.uci.ics.jung.io.GraphMLFileHandler
Throws:
org.xml.sax.SAXException
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
This method is called whenever the SaX parser encounters a closing tag

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

characters

public void characters(char[] ch,
                       int start,
                       int length)
This method is called whenever the SaX parser encounters character content inside a tag

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
See Also:
ContentHandler.characters(char[], int, int)