1 package com.stateofflow.eclipse.metrics.export.csv;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 import com.stateofflow.eclipse.metrics.collator.MetricsCollator;
7 import com.stateofflow.eclipse.metrics.configuration.MetricPresentations;
8 import com.stateofflow.eclipse.metrics.export.Exporter;
9 import com.stateofflow.eclipse.metrics.util.ProgressMonitor;
10
11 public final class CsvExporter implements Exporter {
12 private final File directory;
13 private final MetricPresentations presentations;
14
15 public CsvExporter(final File directory, final MetricPresentations presentations) {
16 this.directory = directory;
17 this.presentations = presentations;
18 }
19
20 public void export(final MetricsCollator typeMetricsCollator, final MetricsCollator methodMetricsCollator, final ProgressMonitor monitor) throws IOException {
21 monitor.beginTask("Exporting CSV", 1);
22
23 write(MetricsWriter.createTypeInstance(presentations), typeMetricsCollator, "Types", monitor);
24 write(MetricsWriter.createMethodInstance(presentations), methodMetricsCollator, "Methods", monitor);
25 }
26
27 private void write(final MetricsWriter metricsWriter, final MetricsCollator collator, final String subTask, final ProgressMonitor monitor) throws IOException {
28 monitor.subTask(subTask);
29 metricsWriter.write(directory, collator);
30 }
31 }
32