You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by cs...@apache.org on 2012/03/20 16:38:23 UTC
svn commit: r1302942 -
/commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/DotExporter.java
Author: cs
Date: Tue Mar 20 15:38:23 2012
New Revision: 1302942
URL: http://svn.apache.org/viewvc?rev=1302942&view=rev
Log:
factored out property writing for edge/vertex and fixed output format (still more to do!) for DOT exporter
Modified:
commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export/DotExporter.java
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=1302942&r1=1302941&r2=1302942&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 Tue Mar 20 15:38:23 2012
@@ -127,17 +127,7 @@ final class DotExporter<V, E>
{
printWriter.format( " %s", vertex.hashCode() );
- if ( !properties.isEmpty() )
- {
- printWriter.write( '[' );
-
- for ( Entry<String, Object> property : properties.entrySet() )
- {
- printWriter.format( "\"%s\"=%s", property.getKey(), property.getValue() );
- }
-
- printWriter.format( "];%n" );
- }
+ printVertexOrEdgeProperties( properties );
}
@Override
@@ -149,13 +139,22 @@ final class DotExporter<V, E>
connector,
tail.hashCode() );
+ printVertexOrEdgeProperties( properties );
+ }
+
+ private void printVertexOrEdgeProperties( Map<String, Object> properties )
+ {
if ( !properties.isEmpty() )
{
- printWriter.write( '[' );
+ int countAddedProperties = 0;
+ printWriter.write( " [" );
for ( Entry<String, Object> property : properties.entrySet() )
{
- printWriter.format( "\"%s\"=%s", property.getKey(), property.getValue() );
+ String formattedString = countAddedProperties == properties.size() - 1 ? "\"%s\"=%s" :
+ "\"%s\"=%s ";
+ printWriter.format( formattedString, property.getKey(), property.getValue() );
+ countAddedProperties++;
}
printWriter.format( "];%n" );