diff --git a/src/main/java/kieker/analysis/graph/export/AbstractTransformer.java b/src/main/java/kieker/analysis/graph/export/AbstractTransformer.java index 08c48d95e42b9131dbe00564f97b00d05d2e6fb2..41983a6312340a90230dc43aa0ba706480a24fa2 100644 --- a/src/main/java/kieker/analysis/graph/export/AbstractTransformer.java +++ b/src/main/java/kieker/analysis/graph/export/AbstractTransformer.java @@ -14,7 +14,7 @@ public abstract class AbstractTransformer<O> implements VertexVisitor, EdgeVisit protected Graph graph; - public AbstractTransformer(final Graph graph) { + protected AbstractTransformer(final Graph graph) { this.graph = graph; } diff --git a/src/main/java/kieker/analysis/graph/export/AbstractWriter.java b/src/main/java/kieker/analysis/graph/export/AbstractWriter.java new file mode 100644 index 0000000000000000000000000000000000000000..789e53c04f264c4a2e068a563da2b40368cb277e --- /dev/null +++ b/src/main/java/kieker/analysis/graph/export/AbstractWriter.java @@ -0,0 +1,38 @@ +package kieker.analysis.graph.export; + +import kieker.analysis.graph.Edge; +import kieker.analysis.graph.Graph; +import kieker.analysis.graph.Vertex; + +public abstract class AbstractWriter extends AbstractTransformer<Void> { + + protected AbstractWriter(final Graph graph) { + super(graph); + start(); + } + + @Override + protected final void mapVertex(final Vertex vertex) { + writeVertex(vertex); + } + + @Override + protected final void mapEdge(final Edge edge) { + writeEdge(edge); + } + + @Override + protected final Void getTransformation() { + finish(); + return null; + } + + protected abstract void start(); + + protected abstract void finish(); + + protected abstract void writeVertex(Vertex vertex); + + protected abstract void writeEdge(Edge edge); + +} diff --git a/src/main/java/kieker/analysis/graph/export/dot/AbstractDotWriter.java b/src/main/java/kieker/analysis/graph/export/dot/AbstractDotWriter.java index bf7f289461bb6d0ebc33687e948f98a56c3c400b..5ede4e0668b1d26aae6feba637ff78f8a7c4a9e8 100644 --- a/src/main/java/kieker/analysis/graph/export/dot/AbstractDotWriter.java +++ b/src/main/java/kieker/analysis/graph/export/dot/AbstractDotWriter.java @@ -6,29 +6,21 @@ import kieker.analysis.graph.Direction; import kieker.analysis.graph.Edge; import kieker.analysis.graph.Graph; import kieker.analysis.graph.Vertex; -import kieker.analysis.graph.export.AbstractTransformer; +import kieker.analysis.graph.export.AbstractWriter; import kieker.analysis.graph.util.dot.DotWriter; //TODo rename, extends AbstractWriter -class AbstractDotWriter extends AbstractTransformer<Void> { +class AbstractDotWriter extends AbstractWriter { protected final DotWriter dotWriter; - AbstractDotWriter(final Graph graph, final DotWriter dotWriter) { + protected AbstractDotWriter(final Graph graph, final DotWriter dotWriter) { super(graph); this.dotWriter = dotWriter; - - // TODO Better put this in own method - try { - dotWriter.start(graph.getName()); - // TODO more stuff - } catch (IOException e) { - // TODO Handle IO Exception - } } @Override - protected void mapVertex(final Vertex vertex) { + protected void writeVertex(final Vertex vertex) { try { if (vertex.hasChildGraph()) { Graph childGraph = vertex.getChildGraph(); @@ -46,28 +38,34 @@ class AbstractDotWriter extends AbstractTransformer<Void> { } } catch (IOException e) { - // TODO Handle IO Exception + handleIOException(e); } } @Override - protected void mapEdge(final Edge edge) { - // TODO Auto-generated method stub - + protected void writeEdge(final Edge edge) { try { - String sourceId = edge.getVertex(Direction.OUT).getId().toString(); String targetId = edge.getVertex(Direction.IN).getId().toString(); dotWriter.addEdge(sourceId, targetId); // TODO } catch (IOException e) { - // TODO Handle IO Exception + handleIOException(e); } } @Override - protected Void getTransformation() { - return null; + protected void start() { + // Do nothing + } + + @Override + protected void finish() { + // Do nothing + } + + protected void handleIOException(final IOException ioException) { + // TODO Handle IO Exception } } diff --git a/src/main/java/kieker/analysis/graph/export/dot/DotWriter2.java b/src/main/java/kieker/analysis/graph/export/dot/DotWriter2.java index 417f897b18abc9b05a726d74e8471d1cf912fe50..ed83a3cfc3a3063b054806166c02994f8b8c49e3 100644 --- a/src/main/java/kieker/analysis/graph/export/dot/DotWriter2.java +++ b/src/main/java/kieker/analysis/graph/export/dot/DotWriter2.java @@ -11,25 +11,26 @@ public class DotWriter2 extends AbstractDotWriter { public DotWriter2(final Graph graph, final Writer writer) { super(graph, new DotWriter(writer)); + } - // TODO Better put this in own method + // TODO does not work so far + @Override + protected void start() { try { dotWriter.start(graph.getName()); // TODO more stuff } catch (IOException e) { - // TODO Handle IO Exception + handleIOException(e); } } @Override - protected Void getTransformation() { - // TODO own method + protected void finish() { try { dotWriter.finish(); } catch (IOException e) { - // TODO Handle IO Exception + handleIOException(e); } - return null; } }