Skip to content

Commit

Permalink
Added friendlier error messages to GraphMLReader.
Browse files Browse the repository at this point in the history
Thanks to Andy Cox for the patch!
  • Loading branch information
jheer committed Jul 15, 2006
1 parent 3122ba1 commit 9d6ad16
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/prefuse/data/io/GraphMLReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,36 @@ public void startDocument() {
m_esch.addColumn(TRGID, String.class);
}

public void endDocument() {
public void endDocument() throws SAXException {
// time to actually set up the edges
IntIterator rows = m_edges.rows();
while ( rows.hasNext() ) {
while (rows.hasNext()) {
int r = rows.nextInt();

String src = m_edges.getString(r, SRCID);
int s = ((Integer)m_nodeMap.get(src)).intValue();
if (!m_nodeMap.containsKey(src)) {
throw new SAXException(
"Tried to create edge with source node id=" + src
+ " which does not exist.");
}
int s = ((Integer) m_nodeMap.get(src)).intValue();
m_edges.setInt(r, SRC, s);

String trg = m_edges.getString(r, TRGID);
int t = ((Integer)m_nodeMap.get(trg)).intValue();
if (!m_nodeMap.containsKey(trg)) {
throw new SAXException(
"Tried to create edge with target node id=" + trg
+ " which does not exist.");
}
int t = ((Integer) m_nodeMap.get(trg)).intValue();
m_edges.setInt(r, TRG, t);
}
m_edges.removeColumn(SRCID);
m_edges.removeColumn(TRGID);

// now create the graph
m_graph = new Graph(m_nodes, m_edges, m_directed);
if ( m_graphid != null )
if (m_graphid != null)
m_graph.putClientProperty(ID, m_graphid);
}

Expand Down

0 comments on commit 9d6ad16

Please sign in to comment.