svn commit: r14664 - trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2008-05-08 03:40:26-0700
New Revision: 14664

Modified:
   trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java

Log:
If we have an error condition then report earlier with some useful info

Modified: trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java?view=diff&rev=14664&p1=trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java&r1=14663&r2=14664
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java	2008-05-08 03:40:26-0700
@@ -313,9 +313,8 @@
      * @param d the Diagram
      */
     private void attachEdges(Diagram d) {
-        for (Iterator it = figEdges.iterator(); it.hasNext(); ) {
-            EdgeData edgeData = (EdgeData) it.next();
-            FigEdge edge = edgeData.getFigEdge();
+        for (EdgeData edgeData : figEdges) {
+            final FigEdge edge = edgeData.getFigEdge();
             
             LOG.info("Setting model element for " + edge);
             
@@ -325,19 +324,15 @@
             }
         }
         
-        for (Iterator it = figEdges.iterator(); it.hasNext(); ) {
-            EdgeData edgeData = (EdgeData) it.next();
-            FigEdge edge = edgeData.getFigEdge();
-            
-            Fig sourcePortFig = null;
-            Fig destPortFig = null;
-            FigNode sourceFigNode = null;
-            FigNode destFigNode = null;
-            
-            sourcePortFig = findFig(edgeData.getSourcePortFigId());
-            destPortFig = findFig(edgeData.getDestPortFigId());
-            sourceFigNode = getFigNode(edgeData.getSourceFigNodeId());
-            destFigNode = getFigNode(edgeData.getDestFigNodeId());
+        for (EdgeData edgeData : figEdges) {
+            final FigEdge edge = edgeData.getFigEdge();
+            
+            Fig sourcePortFig = findFig(edgeData.getSourcePortFigId());
+            Fig destPortFig = findFig(edgeData.getDestPortFigId());
+            final FigNode sourceFigNode =
+                getFigNode(edgeData.getSourceFigNodeId());
+            final FigNode destFigNode =
+                getFigNode(edgeData.getDestFigNodeId());
             
             if (sourceFigNode instanceof FigEdgePort) {
                 sourcePortFig = sourceFigNode;
@@ -480,6 +475,13 @@
          */
         public EdgeData(FigEdge edge, String sourcePortId, 
                 String destPortId, String sourceNodeId, String destNodeId) {
+            if (sourcePortId == null || destPortId == null) {
+                throw new IllegalArgumentException(
+                        "source port and dest port must not be null"
+                        + " source = " + sourcePortId
+                        + " dest = " + destPortId
+                        + " figEdge = " + edge);
+            }
             this.figEdge = edge;
             this.sourcePortFigId = sourcePortId;
             this.destPortFigId = destPortId;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.