Re: svn commit: r1302930 - in /commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export: AbstractExporter.java DotExporter.java GraphMLExporter.java
OH :( I liked the fact that commons properties were defined just once in the Abstract impl :( http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ On Tue, Mar 20, 2012 at 4:14 PM, wrote: > Author: cs > Date: Tue Mar 20 15:14:45 2012 > New Revision: 1302930 > > URL: http://svn.apache.org/viewvc?rev=1302930&view=rev > Log: > removed property setters (withEdgeWeights, etc) from AbstractExporter, > replaced them with protected methods (addEdgeProperty, addVertexProperty) > that can be called by the concrete implementations > > 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=1302930&r1=1302929&r2=1302930&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 > Tue Mar 20 15:14:45 2012 > @@ -62,14 +62,6 @@ abstract class AbstractExporter this.name = name != null ? name : G; > } > > - public abstract T withEdgeWeights( Mapper > edgeWeights ); > - > - public abstract T withVertexWeights( Mapper > vertexWeights ); > - > - public abstract T withEdgeLabels( Mapper edgeLabels ); > - > - public abstract T withVertexLabels( Mapper vertexLabels ); > - > public final void to( File outputFile ) > throws GraphExportException > { > @@ -168,6 +160,16 @@ abstract class AbstractExporter { > return writer; > } > + > + protected void addVertexProperty(String propertyName, Mapper > vertexProperty) > + { > + this.vertexProperties.put(propertyName, vertexProperty); > + } > + > + protected void addEdgeProperty(String propertyName, Mapper > edgeProperty) > + { > + this.edgeProperties.put(propertyName, edgeProperty); > + } > > 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=1302930&r1=1302929&r2=1302930&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:14:45 2012 > @@ -158,28 +158,18 @@ final class DotExporter > } > } > > - @Override > public DotExporter withEdgeWeights( Mapper > edgeWeights ) > { > // TODO Auto-generated method stub > return this; > } > > - @Override > - public DotExporter withVertexWeights( Mapper N> vertexWeights ) > - { > - // TODO Auto-generated method stub > - return this; > - } > - > - @Override > public DotExporter withEdgeLabels( Mapper edgeLabels ) > { > // TODO Auto-generated method stub > return this; > } > > - @Override > public DotExporter withVertexLabels( Mapper vertexLabels > ) > { > // TODO Auto-generated method stub > > 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=1302930&r1=1302929&r2=1302930&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 > Tue Mar 20 15:14:45 2012 > @@ -178,28 +178,24 @@ final class GraphMLExporter > return STRING; > } > > - @Ov
Re: svn commit: r1302930 - in /commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export: AbstractExporter.java DotExporter.java GraphMLExporter.java
Hi Simone, On 20/03/2012 17:35, Simone Tripodi wrote: OH :( I liked the fact that commons properties were defined just once in the Abstract impl :( I did it after realizing that the DOT language does not support weights on vertices. Of course I could have kept the others (withEdgeWeights, withVertexLabels, etc), but we could face the same problem if later we introduce a new format that does not support e.g. labels... WDIT? do you want me to reintegrate the "common denominator" for now? Claudio -- Claudio Squarcella PhD student at Roma Tre University http://www.dia.uniroma3.it/~squarcel http://twitter.com/hyperboreans http://claudio.squarcella.com/ - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: svn commit: r1302930 - in /commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export: AbstractExporter.java DotExporter.java GraphMLExporter.java
Hola, yes I think that having the "common denominator" would help on avoiding to repeat ourselves in various implementations. Methods in the AbstractExporter could be even final, no needs to provide same implementation in the different exporters. All the best, -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ On Tue, Mar 20, 2012 at 5:46 PM, Claudio Squarcella wrote: > Hi Simone, > > > On 20/03/2012 17:35, Simone Tripodi wrote: >> >> OH :( I liked the fact that commons properties were defined just once >> in the Abstract impl :( > > > I did it after realizing that the DOT language does not support weights on > vertices. Of course I could have kept the others (withEdgeWeights, > withVertexLabels, etc), but we could face the same problem if later we > introduce a new format that does not support e.g. labels... > > WDIT? do you want me to reintegrate the "common denominator" for now? > > Claudio > > -- > Claudio Squarcella > PhD student at Roma Tre University > http://www.dia.uniroma3.it/~squarcel > http://twitter.com/hyperboreans > http://claudio.squarcella.com/ > > > - > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: svn commit: r1302930 - in /commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export: AbstractExporter.java DotExporter.java GraphMLExporter.java
Hi, yes I think that having the "common denominator" would help on avoiding to repeat ourselves in various implementations. Methods in the AbstractExporter could be even final, no needs to provide same implementation in the different exporters. the thing is: even if (for example) edge weights are supported in ALL the file formats of the world (which is quite plausible), the actual attribute will likely be called in different ways for each format: "weight", "w", "value" or whatever. So even a unified implementation in AbstractExporter should still rely on concrete implementations to discover the name of the attribute (see e.g. the static fields DotExporter.WEIGHT and DotExporter.LABEL). But it's still fine for me to keep at least the abstract common denominator. Another issue I'm facing: some of the output formats depend on the actual type of the printed value. For example in the DOT format, Strings (especially those with whitespaces) should be double-quoted while numbers (doubles) should not, e.g.: * 192 [label="hello world" weight=3.4] So we should also seek a unified way to keep track of attribute types when serializing them, so that each exporter can choose the appropriate output format for each of them. I saw the "enlistVerticesProperty"/"enlistEdgesProperty" methods in the code, are they supposed to help on this matter? Ciao, Claudio -- Claudio Squarcella PhD student at Roma Tre University http://www.dia.uniroma3.it/~squarcel http://twitter.com/hyperboreans http://claudio.squarcella.com/ - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org
Re: svn commit: r1302930 - in /commons/sandbox/graph/branches/exporters-with-mappers/src/main/java/org/apache/commons/graph/export: AbstractExporter.java DotExporter.java GraphMLExporter.java
Hi Claudio, > the thing is: even if (for example) edge weights are supported in ALL the > file formats of the world (which is quite plausible), the actual attribute > will likely be called in different ways for each format: "weight", "w", > "value" or whatever. So even a unified implementation in AbstractExporter > should still rely on concrete implementations to discover the name of the > attribute (see e.g. the static fields DotExporter.WEIGHT and > DotExporter.LABEL). OK! > But it's still fine for me to keep at least the abstract > common denominator. OK sounds a reasonable compromise! > > Another issue I'm facing: some of the output formats depend on the actual > type of the printed value. For example in the DOT format, Strings > (especially those with whitespaces) should be double-quoted while numbers > (doubles) should not, e.g.: > > * 192 [label="hello world" weight=3.4] > > So we should also seek a unified way to keep track of attribute types when > serializing them, so that each exporter can choose the appropriate output > format for each of them. I saw the > "enlistVerticesProperty"/"enlistEdgesProperty" methods in the code, are they > supposed to help on this matter? > I honestly started prototyping that method because of the need of GraphML of enlisting all properties first :S Can't you discover the propert type simply by checking the returned object class? Thanks for taking care of it! -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ - To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org