commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1302671 - in /commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export: AbstractExporter.java DefaultToStreamBuilder.java DotExporter.java GraphMLExporter.java ToStreamBuilder.java
Date Mon, 19 Mar 2012 21:48:57 GMT
Author: simonetripodi
Date: Mon Mar 19 21:48:57 2012
New Revision: 1302671

URL: http://svn.apache.org/viewvc?rev=1302671&view=rev
Log:
reintegrated stream builders
dropped no longer used used constructors

Removed:
    commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/DefaultToStreamBuilder.java
    commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/ToStreamBuilder.java
Modified:
    commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/AbstractExporter.java
    commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/DotExporter.java
    commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/GraphMLExporter.java

Modified: commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/AbstractExporter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/AbstractExporter.java?rev=1302671&r1=1302670&r2=1302671&view=diff
==============================================================================
--- commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/AbstractExporter.java
(original)
+++ commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/AbstractExporter.java
Mon Mar 19 21:48:57 2012
@@ -20,10 +20,14 @@ package org.apache.commons.graph.export;
  */
 
 import static java.lang.String.format;
+import static org.apache.commons.graph.utils.Assertions.checkNotNull;
 
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.util.Date;
 import java.util.HashMap;
@@ -41,25 +45,13 @@ abstract class AbstractExporter<V, E, T 
 
     private final Graph<V, E> graph;
 
-    private final Writer writer;
-
     private final Map<String, Mapper<V, ?>> vertexProperties;
 
     private final Map<String, Mapper<E, ?>> edgeProperties;
 
     private final String name;
 
-    public AbstractExporter( Graph<V, E> graph, Writer writer,
-                             Map<String, Mapper<V, ?>> vertexProperties,
-                             Map<String, Mapper<E, ?>> edgeProperties,
-                             String name )
-    {
-        this.graph = graph;
-        this.writer = writer;
-        this.vertexProperties = vertexProperties;
-        this.edgeProperties = edgeProperties;
-        this.name = name != null ? name : G;
-    }
+    private Writer writer;
 
     public AbstractExporter( Graph<V, E> graph )
     {
@@ -83,34 +75,30 @@ abstract class AbstractExporter<V, E, T 
 
     public abstract T withVertexLabels( Mapper<V, String> vertexLabels );
 
-    public void to( File outputFile )
-    {
-        // TODO
-    }
-
-    public void to( OutputStream outputStream )
-    {
-        // TODO
-    }
-
-    public void to( Writer writer )
-    {
-        // TODO
-    }
-
-    protected final Graph<V, E> getGraph()
+    public final void to( File outputFile )
+        throws GraphExportException
     {
-        return graph;
+        try
+        {
+            to( new FileOutputStream( checkNotNull( outputFile, "Impossibe to export the
graph in a null file" ) ) );
+        }
+        catch ( FileNotFoundException e )
+        {
+            throw new RuntimeException( e );
+        }
     }
 
-    protected final Writer getWriter()
+    public final void to( OutputStream outputStream )
+        throws GraphExportException
     {
-        return writer;
+        to( new OutputStreamWriter( checkNotNull( outputStream, "Impossibe to export the
graph in a null stream" ) ) );
     }
 
-    public final void export()
+    public final void to( Writer writer )
         throws GraphExportException
     {
+        this.writer = checkNotNull( writer, "Impossibe to export the graph in a null stream"
);
+
         try
         {
             startSerialization();
@@ -176,6 +164,16 @@ abstract class AbstractExporter<V, E, T 
         }
     }
 
+    protected final Graph<V, E> getGraph()
+    {
+        return graph;
+    }
+
+    protected final Writer getWriter()
+    {
+        return writer;
+    }
+
     protected abstract void startSerialization()
         throws Exception;
 

Modified: commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/DotExporter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/DotExporter.java?rev=1302671&r1=1302670&r2=1302671&view=diff
==============================================================================
--- commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/DotExporter.java
(original)
+++ commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/DotExporter.java
Mon Mar 19 21:48:57 2012
@@ -20,7 +20,6 @@ package org.apache.commons.graph.export;
  */
 
 import java.io.PrintWriter;
-import java.io.Writer;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -46,14 +45,6 @@ final class DotExporter<V, E>
 
     private static final String DICONNECTOR = "->";
 
-    public DotExporter( Graph<V, E> graph, Writer writer,
-                        Map<String, Mapper<V, ?>> vertexProperties,
-                        Map<String, Mapper<E, ?>> edgeProperties,
-                        String name )
-    {
-        super( graph, writer, vertexProperties, edgeProperties, name );
-    }
-
     public DotExporter(Graph<V, E> graph) {
     	super( graph );
 	}

Modified: commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/GraphMLExporter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/GraphMLExporter.java?rev=1302671&r1=1302670&r2=1302671&view=diff
==============================================================================
--- commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/GraphMLExporter.java
(original)
+++ commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/GraphMLExporter.java
Mon Mar 19 21:48:57 2012
@@ -19,8 +19,6 @@ package org.apache.commons.graph.export;
  * under the License.
  */
 
-import java.io.Writer;
-import java.util.Collection;
 import java.util.Map;
 
 import org.apache.commons.graph.Graph;
@@ -78,14 +76,6 @@ final class GraphMLExporter<V, E>
 
     private static final String WEIGHT = "weight";
 
-    public GraphMLExporter( Graph<V, E> graph, Writer writer,
-                            Map<String, Mapper<V, ?>> vertexProperties,
-                            Map<String, Mapper<E, ?>> edgeProperties,
-                            String name )
-    {
-        super( graph, writer, vertexProperties, edgeProperties, name );
-    }
-
     public GraphMLExporter(Graph<V, E> graph) {
     	super( graph );
 	}



Mime
View raw message