GraphMLReader2 implements GraphReader<G, N, E> { @SuppressWarnings("unchecked") public G readGraph() throws GraphIOException { try { init(); while (xmlEventReader.hasNext()) { XMLEvent event = xmlEventReader.nextEvent(); if (event.isStartElement()) { StartElement element = (StartElement) event; String name = element.getName().getLocalPart(); if (GraphMLConstants.KEY_NAME.equals(name)) { Key key = (Key) parserRegistry.getParser(name).parse(xmlEventReader, element); document.getKeyMap().addKey(key); } else if (GraphMLConstants.GRAPH_NAME.equals(name)) { GraphMetadata graph = (GraphMetadata) parserRegistry.getParser(name).parse(xmlEventReader, element); document.getGraphMetadata().add(graph); return (G) graph.getGraph(); } else if (GraphMLConstants.GRAPHML_NAME.equals(name)) { } else { parserRegistry.getUnknownElementParser().parse(xmlEventReader, element); } } else if (event.isEndDocument()) { break; } } } catch (Exception e) { ExceptionConverter.convert(e); } throw new GraphIOException("Unable to read Graph from document - the document could be empty"); } GraphMLReader2(
      Reader fileReader,
      Function<GraphMetadata, G> graphTransformer,
      Function<NodeMetadata, N> nodeTransformer,
      Function<EdgeMetadata, E> edgeTransformer);  GraphMLReader2(
      InputStream inputStream,
      Function<GraphMetadata, G> graphTransformer,
      Function<NodeMetadata, N> nodeTransformer,
      Function<EdgeMetadata, E> edgeTransformer); Function<GraphMetadata, G> getGraphTransformer(); Function<NodeMetadata, N> getNodeTransformer(); Function<EdgeMetadata, E> getEdgeTransformer(); void init(); void close(); GraphMLDocument getGraphMLDocument(); @SuppressWarnings("unchecked") G readGraph();  }
@Test(expected = GraphIOException.class) public void testEdgeWithInvalidNode() throws Exception { String xml = graphMLDocStart + "<key id=\"d0\" for=\"node\" attr.name=\"color\" attr.type=\"string\">" + "<default>yellow</default>" + "</key>" + "<key id=\"d1\" for=\"edge\" attr.name=\"weight\" attr.type=\"double\"/>" + "<graph id=\"G\" edgedefault=\"undirected\">" + "<node id=\"n0\">" + "<data key=\"d0\">green</data>" + "</node>" + "<node id=\"n1\"/>" + "<node id=\"n2\">" + "<data key=\"d0\">blue</data>" + "</node>" + "<edge id=\"e0\" source=\"n0\" target=\"n3\">" + "<data key=\"d1\">1.0</data>" + "</edge>" + "</graphml>"; readGraph( xml, new DummyGraphObjectBase.UndirectedNetworkFactory(), new DummyNode.Factory(), new DummyEdge.EdgeFactory()); }
@Test(expected = GraphIOException.class) public void testEmptyFile() throws Exception { String xml = ""; readGraph( xml, new DummyGraphObjectBase.UndirectedNetworkFactory(), new DummyNode.Factory(), new DummyEdge.EdgeFactory()); }