commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1305060 - in /commons/sandbox/graph/trunk/src: main/java/org/apache/commons/graph/ main/java/org/apache/commons/graph/export/ test/java/org/apache/commons/graph/export/
Date Sun, 25 Mar 2012 15:21:41 GMT
Author: simonetripodi
Date: Sun Mar 25 15:21:40 2012
New Revision: 1305060

URL: http://svn.apache.org/viewvc?rev=1305060&view=rev
Log:
NamedExportSelector reintegrated in the builder chain

Modified:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DefaultExportSelector.java
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/ExportSelector.java
    commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/export/ExportTestCase.java

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java?rev=1305060&r1=1305059&r2=1305060&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/CommonsGraph.java Sun
Mar 25 15:21:40 2012
@@ -36,7 +36,7 @@ import org.apache.commons.graph.coloring
 import org.apache.commons.graph.connectivity.ConnectivityBuilder;
 import org.apache.commons.graph.connectivity.DefaultConnectivityBuilder;
 import org.apache.commons.graph.export.DefaultExportSelector;
-import org.apache.commons.graph.export.ExportSelector;
+import org.apache.commons.graph.export.NamedExportSelector;
 import org.apache.commons.graph.flow.DefaultFlowWeightedEdgesBuilder;
 import org.apache.commons.graph.flow.FlowWeightedEdgesBuilder;
 import org.apache.commons.graph.model.DirectedMutableGraph;
@@ -56,7 +56,7 @@ import org.apache.commons.graph.visit.Vi
 public final class CommonsGraph<V, E, G extends Graph<V, E>>
 {
 
-    public static <V, E, G extends Graph<V, E>> ExportSelector<V, E> export(
G graph )
+    public static <V, E, G extends Graph<V, E>> NamedExportSelector<V, E>
export( G graph )
     {
         graph = checkNotNull( graph, "Null graph can not be exported" );
         return new DefaultExportSelector<V, E>( graph );

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DefaultExportSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DefaultExportSelector.java?rev=1305060&r1=1305059&r2=1305060&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DefaultExportSelector.java
(original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/DefaultExportSelector.java
Sun Mar 25 15:21:40 2012
@@ -19,14 +19,18 @@ package org.apache.commons.graph.export;
  * under the License.
  */
 
+import static org.apache.commons.graph.utils.Assertions.checkNotNull;
+
 import org.apache.commons.graph.Graph;
 
 public final class DefaultExportSelector<V, E>
-    implements ExportSelector<V, E>
+    implements NamedExportSelector<V, E>
 {
 
     private final Graph<V, E> graph;
 
+    private String name = null;
+
     public DefaultExportSelector( Graph<V, E> graph )
     {
         this.graph = graph;
@@ -34,22 +38,18 @@ public final class DefaultExportSelector
 
     public DotExporter<V, E> usingDotNotation()
     {
-        return new DotExporter<V, E>( graph, null );
-    }
-
-    public DotExporter<V, E> usingDotNotation( String name )
-    {
         return new DotExporter<V, E>( graph, name );
     }
 
     public GraphMLExporter<V, E> usingGraphMLFormat()
     {
-        return new GraphMLExporter<V, E>( graph, null );
+        return new GraphMLExporter<V, E>( graph, name );
     }
 
-    public GraphMLExporter<V, E> usingGraphMLFormat( String name )
+    public ExportSelector<V, E> withName( String name )
     {
-        return new GraphMLExporter<V, E>( graph, name );
+        this.name = checkNotNull( name, "Graph name cannot be null." );
+        return this;
     }
 
 }

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/ExportSelector.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/ExportSelector.java?rev=1305060&r1=1305059&r2=1305060&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/ExportSelector.java
(original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/export/ExportSelector.java
Sun Mar 25 15:21:40 2012
@@ -28,16 +28,10 @@ public interface ExportSelector<V, E>
     DotExporter<V, E> usingDotNotation()
         throws GraphExportException;
 
-    DotExporter<V, E> usingDotNotation( String name )
-        throws GraphExportException;
-
     /**
      * Export Graphs in <a href="http://graphml.graphdrawing.org/">GraphML file format</a>.
      */
     GraphMLExporter<V, E> usingGraphMLFormat()
         throws GraphExportException;
 
-    GraphMLExporter<V, E> usingGraphMLFormat( String name )
-            throws GraphExportException;
-
 }

Modified: commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/export/ExportTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/export/ExportTestCase.java?rev=1305060&r1=1305059&r2=1305060&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/export/ExportTestCase.java
(original)
+++ commons/sandbox/graph/trunk/src/test/java/org/apache/commons/graph/export/ExportTestCase.java
Sun Mar 25 15:21:40 2012
@@ -68,7 +68,8 @@ public class ExportTestCase {
     public void shouldPrintDotFormat()
         throws Exception
     {
-        export( actual ).usingDotNotation()
+        export( actual ).withName( "DotFormatGraph" )
+                        .usingDotNotation()
                         .withVertexLabels( new VertexLabelMapper() )
                         .withEdgeWeights( new EdgeWeightMapper() )
                         .withEdgeLabels( new EdgeLabelMapper() )
@@ -80,7 +81,8 @@ public class ExportTestCase {
     public void shouldPrintGraphML()
         throws Exception
     {
-        export( actual ).usingGraphMLFormat()
+        export( actual ).withName( "GraphMLGraph" )
+                        .usingGraphMLFormat()
                         .withVertexLabels( new VertexLabelMapper() )
                         .withEdgeWeights( new EdgeWeightMapper() )
                         .withEdgeLabels( new EdgeLabelMapper() )



Mime
View raw message