Skip to content
Snippets Groups Projects
Commit e1c93d6b authored by Sören Henning's avatar Sören Henning
Browse files

organize writers hierarchy

parent 853bea0d
No related branches found
No related tags found
1 merge request!17Get impletemented stages and Java 8
...@@ -14,7 +14,7 @@ public abstract class AbstractTransformer<O> implements VertexVisitor, EdgeVisit ...@@ -14,7 +14,7 @@ public abstract class AbstractTransformer<O> implements VertexVisitor, EdgeVisit
protected Graph graph; protected Graph graph;
public AbstractTransformer(final Graph graph) { protected AbstractTransformer(final Graph graph) {
this.graph = graph; this.graph = graph;
} }
......
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);
}
...@@ -6,29 +6,21 @@ import kieker.analysis.graph.Direction; ...@@ -6,29 +6,21 @@ import kieker.analysis.graph.Direction;
import kieker.analysis.graph.Edge; import kieker.analysis.graph.Edge;
import kieker.analysis.graph.Graph; import kieker.analysis.graph.Graph;
import kieker.analysis.graph.Vertex; import kieker.analysis.graph.Vertex;
import kieker.analysis.graph.export.AbstractTransformer; import kieker.analysis.graph.export.AbstractWriter;
import kieker.analysis.graph.util.dot.DotWriter; import kieker.analysis.graph.util.dot.DotWriter;
//TODo rename, extends AbstractWriter //TODo rename, extends AbstractWriter
class AbstractDotWriter extends AbstractTransformer<Void> { class AbstractDotWriter extends AbstractWriter {
protected final DotWriter dotWriter; protected final DotWriter dotWriter;
AbstractDotWriter(final Graph graph, final DotWriter dotWriter) { protected AbstractDotWriter(final Graph graph, final DotWriter dotWriter) {
super(graph); super(graph);
this.dotWriter = dotWriter; 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 @Override
protected void mapVertex(final Vertex vertex) { protected void writeVertex(final Vertex vertex) {
try { try {
if (vertex.hasChildGraph()) { if (vertex.hasChildGraph()) {
Graph childGraph = vertex.getChildGraph(); Graph childGraph = vertex.getChildGraph();
...@@ -46,28 +38,34 @@ class AbstractDotWriter extends AbstractTransformer<Void> { ...@@ -46,28 +38,34 @@ class AbstractDotWriter extends AbstractTransformer<Void> {
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Handle IO Exception handleIOException(e);
} }
} }
@Override @Override
protected void mapEdge(final Edge edge) { protected void writeEdge(final Edge edge) {
// TODO Auto-generated method stub
try { try {
String sourceId = edge.getVertex(Direction.OUT).getId().toString(); String sourceId = edge.getVertex(Direction.OUT).getId().toString();
String targetId = edge.getVertex(Direction.IN).getId().toString(); String targetId = edge.getVertex(Direction.IN).getId().toString();
dotWriter.addEdge(sourceId, targetId); // TODO dotWriter.addEdge(sourceId, targetId); // TODO
} catch (IOException e) { } catch (IOException e) {
// TODO Handle IO Exception handleIOException(e);
} }
} }
@Override @Override
protected Void getTransformation() { protected void start() {
return null; // Do nothing
}
@Override
protected void finish() {
// Do nothing
}
protected void handleIOException(final IOException ioException) {
// TODO Handle IO Exception
} }
} }
...@@ -11,25 +11,26 @@ public class DotWriter2 extends AbstractDotWriter { ...@@ -11,25 +11,26 @@ public class DotWriter2 extends AbstractDotWriter {
public DotWriter2(final Graph graph, final Writer writer) { public DotWriter2(final Graph graph, final Writer writer) {
super(graph, new DotWriter(writer)); super(graph, new DotWriter(writer));
}
// TODO Better put this in own method // TODO does not work so far
@Override
protected void start() {
try { try {
dotWriter.start(graph.getName()); dotWriter.start(graph.getName());
// TODO more stuff // TODO more stuff
} catch (IOException e) { } catch (IOException e) {
// TODO Handle IO Exception handleIOException(e);
} }
} }
@Override @Override
protected Void getTransformation() { protected void finish() {
// TODO own method
try { try {
dotWriter.finish(); dotWriter.finish();
} catch (IOException e) { } catch (IOException e) {
// TODO Handle IO Exception handleIOException(e);
} }
return null;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment