You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/06/24 16:51:29 UTC

svn commit: r1139343 - in /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph: ./ shortestpath/

Author: simonetripodi
Date: Fri Jun 24 14:51:29 2011
New Revision: 1139343

URL: http://svn.apache.org/viewvc?rev=1139343&view=rev
Log:
avoid to format exception messages outside the exception, simplified the string format centralizing it in the GraphException

Modified:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/GraphException.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/NegativeWeightedCycleException.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathNotFoundException.java

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/GraphException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/GraphException.java?rev=1139343&r1=1139342&r2=1139343&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/GraphException.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/GraphException.java Fri Jun 24 14:51:29 2011
@@ -19,6 +19,7 @@ package org.apache.commons.graph;
  * under the License.
  */
 
+import static java.lang.String.format;
 
 /**
  * GraphException This is the superclass of all exceptions that can be thrown.
@@ -40,11 +41,13 @@ public class GraphException
     /**
      * Constructs a new graph exception with the specified detail message.
      *
-     * @param msg the detail message.
+     * @param messagePattern The error message text pattern
+     * @param arguments Arguments referenced by the format specifiers in the format string
+     * @see java.lang.String#format(String, Object...)
      */
-    public GraphException( String msg )
+    public GraphException( String messagePattern, Object...arguments )
     {
-        super(msg);
+        super( format( messagePattern, arguments ) );
     }
 
     /**

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java?rev=1139343&r1=1139342&r2=1139343&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java Fri Jun 24 14:51:29 2011
@@ -19,8 +19,6 @@ package org.apache.commons.graph.shortes
  * under the License.
  */
 
-import static java.lang.String.format;
-
 import java.util.HashSet;
 import java.util.PriorityQueue;
 import java.util.Set;
@@ -116,8 +114,7 @@ public final class AStar
             }
         }
 
-        throw new PathNotFoundException( format( "Path from '%s' to '%s' doesn't exist in Graph '%s'", start, goal,
-                                                 graph ) );
+        throw new PathNotFoundException( "Path from '%s' to '%s' doesn't exist in Graph '%s'", start, goal, graph );
     }
 
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java?rev=1139343&r1=1139342&r2=1139343&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AllVertexPairsShortestPath.java Fri Jun 24 14:51:29 2011
@@ -19,8 +19,6 @@ package org.apache.commons.graph.shortes
  * under the License.
  */
 
-import static java.lang.String.format;
-
 import java.util.HashMap;
 import java.util.Map;
 
@@ -95,7 +93,7 @@ public final class AllVertexPairsShortes
 
         if ( path == null )
         {
-            throw new PathNotFoundException( format( "Path from '%s' to '%s' doesn't exist", source, target ) );
+            throw new PathNotFoundException( "Path from '%s' to '%s' doesn't exist", source, target );
         }
 
         return path;

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java?rev=1139343&r1=1139342&r2=1139343&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/Dijkstra.java Fri Jun 24 14:51:29 2011
@@ -19,8 +19,6 @@ package org.apache.commons.graph.shortes
  * under the License.
  */
 
-import static java.lang.String.format;
-
 import java.util.HashSet;
 import java.util.PriorityQueue;
 import java.util.Set;
@@ -106,8 +104,7 @@ public final class Dijkstra
             }
         }
 
-        throw new PathNotFoundException( format( "Path from '%s' to '%s' doesn't exist in Graph '%s'", source, target,
-                                                 graph ) );
+        throw new PathNotFoundException( "Path from '%s' to '%s' doesn't exist in Graph '%s'", source, target, graph );
     }
 
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/NegativeWeightedCycleException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/NegativeWeightedCycleException.java?rev=1139343&r1=1139342&r2=1139343&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/NegativeWeightedCycleException.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/NegativeWeightedCycleException.java Fri Jun 24 14:51:29 2011
@@ -30,9 +30,9 @@ public final class NegativeWeightedCycle
 
     private static final long serialVersionUID = 3196711750285223435L;
 
-    public NegativeWeightedCycleException( String msg )
+    public NegativeWeightedCycleException( String messagePattern, Object...arguments )
     {
-        super( msg );
+        super( messagePattern, arguments );
     }
 
     public NegativeWeightedCycleException( Throwable cause )

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathNotFoundException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathNotFoundException.java?rev=1139343&r1=1139342&r2=1139343&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathNotFoundException.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/PathNotFoundException.java Fri Jun 24 14:51:29 2011
@@ -27,9 +27,9 @@ public final class PathNotFoundException
 
     private static final long serialVersionUID = 2919520319054603708L;
 
-    public PathNotFoundException( String msg )
+    public PathNotFoundException( String messagePattern, Object...arguments )
     {
-        super( msg );
+        super( messagePattern, arguments );
     }
 
 }