| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
edu.uci.ics.jung.io.GraphMLReader<G,V,E>
public class GraphMLReader<G extends Hypergraph<V,E>,V,E>
Reads in data from a GraphML-formatted file and generates graphs based on that data. Currently supports the following parts of the GraphML specification:
data
 graph, vertex, edge descriptions and data descriptions
 vertex and edge IDs
 get methods.
 Does not currently support nested graphs or ports.
 Note that the user is responsible for supplying a graph
 Factory that can support the edge types in the supplied
 GraphML file.  If the graph generated by the Factory is
 not compatible (for example: if the graph does not accept directed
 edges, and the GraphML file contains a directed edge) then the results
 are graph-implementation-dependent.
| Nested Class Summary | |
|---|---|
| protected static class | GraphMLReader.KeyType | 
| protected static class | GraphMLReader.TagState | 
| Field Summary | |
|---|---|
| protected  E | current_edge | 
| protected  G | current_graph | 
| protected  String | current_key | 
| protected  LinkedList<GraphMLReader.TagState> | current_states | 
| protected  V | current_vertex | 
| protected  EdgeType | default_edgetype | 
| protected  Map<E,String> | edge_desc | 
| protected  org.apache.commons.collections15.Factory<E> | edge_factory | 
| protected  org.apache.commons.collections15.BidiMap<E,String> | edge_ids | 
| protected  Map<String,GraphMLMetadata<E>> | edge_metadata | 
| protected  Map<G,String> | graph_desc | 
| protected  org.apache.commons.collections15.Factory<G> | graph_factory | 
| protected  Map<String,GraphMLMetadata<G>> | graph_metadata | 
| protected  List<G> | graphs | 
| protected  Collection<V> | hyperedge_vertices | 
| protected  GraphMLReader.KeyType | key_type | 
| protected  SAXParser | saxp | 
| protected  org.apache.commons.collections15.BidiMap<String,GraphMLReader.TagState> | tag_state | 
| protected  Map<V,String> | vertex_desc | 
| protected  org.apache.commons.collections15.Factory<V> | vertex_factory | 
| protected  org.apache.commons.collections15.BidiMap<V,String> | vertex_ids | 
| protected  Map<String,GraphMLMetadata<V>> | vertex_metadata | 
| Constructor Summary | |
|---|---|
| GraphMLReader()Creates a GraphMLReaderinstance that assigns the vertex
 and edgeidstrings to be the vertex and edge objects,
 as well as their IDs. | |
| GraphMLReader(org.apache.commons.collections15.Factory<V> vertex_factory,
              org.apache.commons.collections15.Factory<E> edge_factory)Creates a GraphMLReaderinstance with the specified
 vertex and edge factories. | |
| Method Summary | ||
|---|---|---|
| protected 
 | addDatum(Map<String,GraphMLMetadata<T>> metadata,
         T current_elt,
         String text) | |
| protected 
 | addExtraData(Map<String,String> atts,
             Map<String,GraphMLMetadata<T>> metadata_map,
             T current_elt) | |
| protected  void | assignEdgeSourceTarget(E e,
                       Attributes atts,
                       Map<String,String> edge_atts) | |
|  void | characters(char[] ch,
           int start,
           int length) | |
| protected  void | clearData() | |
| protected  void | createEdge(Attributes atts,
           GraphMLReader.TagState state) | |
| protected  void | createKey(Attributes atts) | |
| protected  void | createVertex(Attributes atts) | |
|  void | endElement(String uri,
           String name,
           String qName) | |
| protected  Map<String,String> | getAttributeMap(Attributes atts) | |
|  Map<E,String> | getEdgeDescriptions()Returns a map from edges to edge descriptions. | |
|  org.apache.commons.collections15.BidiMap<E,String> | getEdgeIDs()Returns a bidirectional map relating edges and IDs. | |
|  Map<String,GraphMLMetadata<E>> | getEdgeMetadata()Returns a map from edge type name to type metadata. | |
|  Map<G,String> | getGraphDescriptions()Returns a map from graphs to graph descriptions. | |
|  Map<String,GraphMLMetadata<G>> | getGraphMetadata()Returns a map from graph type name to type metadata. | |
|  Map<V,String> | getVertexDescriptions()Returns a map from vertices to vertex descriptions. | |
|  org.apache.commons.collections15.BidiMap<V,String> | getVertexIDs()Returns a bidirectional map relating vertices and IDs. | |
|  Map<String,GraphMLMetadata<V>> | getVertexMetadata()Returns a map from vertex type name to type metadata. | |
| protected  void | handleData(Attributes atts) | |
| protected  void | initializeData()This is separate from initialize() because these data structures are shared among all graphs loaded (i.e., they're defined inside graphmlrather thangraph. | |
|  void | load(Reader reader,
     G g)Populates the specified graph with the data parsed from the reader. | |
|  void | load(String filename,
     G g)Populates the specified graph with the data parsed from the specified file. | |
|  List<G> | loadMultiple(Reader reader,
             org.apache.commons.collections15.Factory<G> graph_factory)Returns a list of the graphs parsed from the specified reader, as created by the specified factory. | |
|  List<G> | loadMultiple(String filename,
             org.apache.commons.collections15.Factory<G> graph_factory)Returns a list of the graphs parsed from the specified file, as created by the specified factory. | |
| protected  void | parse(Reader reader) | |
|  void | startElement(String uri,
             String name,
             String qName,
             Attributes atts) | |
| 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 | 
|---|
protected SAXParser saxp
protected EdgeType default_edgetype
protected G extends Hypergraph<V,E> current_graph
protected V current_vertex
protected E current_edge
protected String current_key
protected LinkedList<GraphMLReader.TagState> current_states
protected org.apache.commons.collections15.BidiMap<String,GraphMLReader.TagState> tag_state
protected org.apache.commons.collections15.Factory<G extends Hypergraph<V,E>> graph_factory
protected org.apache.commons.collections15.Factory<V> vertex_factory
protected org.apache.commons.collections15.Factory<E> edge_factory
protected org.apache.commons.collections15.BidiMap<V,String> vertex_ids
protected org.apache.commons.collections15.BidiMap<E,String> edge_ids
protected Map<String,GraphMLMetadata<G extends Hypergraph<V,E>>> graph_metadata
protected Map<String,GraphMLMetadata<V>> vertex_metadata
protected Map<String,GraphMLMetadata<E>> edge_metadata
protected Map<V,String> vertex_desc
protected Map<E,String> edge_desc
protected Map<G extends Hypergraph<V,E>,String> graph_desc
protected GraphMLReader.KeyType key_type
protected Collection<V> hyperedge_vertices
protected List<G extends Hypergraph<V,E>> graphs
| Constructor Detail | 
|---|
public GraphMLReader(org.apache.commons.collections15.Factory<V> vertex_factory,
                     org.apache.commons.collections15.Factory<E> edge_factory)
              throws ParserConfigurationException,
                     SAXException
GraphMLReader instance with the specified
 vertex and edge factories.
vertex_factory - the vertex factory to use to create vertex objectsedge_factory - the edge factory to use to create edge objects
ParserConfigurationException
SAXException
public GraphMLReader()
              throws ParserConfigurationException,
                     SAXException
GraphMLReader instance that assigns the vertex
 and edge id strings to be the vertex and edge objects,
 as well as their IDs.
 Note that this requires that (a) each edge have a valid ID, which is not
 normally a requirement for edges in GraphML, and (b) that the vertex
 and edge types be assignment-compatible with String.
ParserConfigurationException
SAXException| Method Detail | 
|---|
public List<G> loadMultiple(Reader reader,
                            org.apache.commons.collections15.Factory<G> graph_factory)
                                             throws IOException
IOException
public List<G> loadMultiple(String filename,
                            org.apache.commons.collections15.Factory<G> graph_factory)
                                             throws IOException
IOException
public void load(Reader reader,
                 G g)
          throws IOException
IOException
public void load(String filename,
                 G g)
          throws IOException
IOExceptionprotected void clearData()
protected void initializeData()
graphml rather than graph.
protected void parse(Reader reader)
              throws IOException
IOException
public void startElement(String uri,
                         String name,
                         String qName,
                         Attributes atts)
                  throws SAXNotSupportedException
startElement in interface ContentHandlerstartElement in class DefaultHandlerSAXNotSupportedException
protected <T> void addExtraData(Map<String,String> atts,
                                Map<String,GraphMLMetadata<T>> metadata_map,
                                T current_elt)
T - atts - metadata_map - current_elt - 
public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXNotSupportedException
characters in interface ContentHandlercharacters in class DefaultHandlerSAXNotSupportedException
protected <T> void addDatum(Map<String,GraphMLMetadata<T>> metadata,
                            T current_elt,
                            String text)
                 throws SAXNotSupportedException
SAXNotSupportedException
public void endElement(String uri,
                       String name,
                       String qName)
                throws SAXNotSupportedException
endElement in interface ContentHandlerendElement in class DefaultHandlerSAXNotSupportedExceptionprotected Map<String,String> getAttributeMap(Attributes atts)
protected void handleData(Attributes atts)
                   throws SAXNotSupportedException
SAXNotSupportedException
protected void createKey(Attributes atts)
                  throws SAXNotSupportedException
SAXNotSupportedException
protected void createVertex(Attributes atts)
                     throws SAXNotSupportedException
SAXNotSupportedException
protected void createEdge(Attributes atts,
                          GraphMLReader.TagState state)
                   throws SAXNotSupportedException
SAXNotSupportedException
protected void assignEdgeSourceTarget(E e,
                                      Attributes atts,
                                      Map<String,String> edge_atts)
                               throws SAXNotSupportedException
SAXNotSupportedExceptionpublic org.apache.commons.collections15.BidiMap<V,String> getVertexIDs()
public org.apache.commons.collections15.BidiMap<E,String> getEdgeIDs()
public Map<String,GraphMLMetadata<G>> getGraphMetadata()
public Map<String,GraphMLMetadata<V>> getVertexMetadata()
public Map<String,GraphMLMetadata<E>> getEdgeMetadata()
public Map<G,String> getGraphDescriptions()
public Map<V,String> getVertexDescriptions()
public Map<E,String> getEdgeDescriptions()
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||