1 package com.stateofflow.eclipse.metrics.export.csv;
2
3 import java.io.PrintWriter;
4
5 import com.stateofflow.eclipse.metrics.configuration.MetricPresentations;
6 import com.stateofflow.eclipse.metrics.metric.MetricId;
7
8 final class HeaderWriter {
9 private final String identifyingColumns;
10 private final MetricPresentations presentations;
11
12 public HeaderWriter(final String identifyingColumns, final MetricPresentations presentations) {
13 this.identifyingColumns = identifyingColumns;
14 this.presentations = presentations;
15 }
16
17 public void write(final PrintWriter writer, final MetricId[] metricIds) {
18 writer.print(identifyingColumns);
19 writeMetricNamesHeaderFragment(writer, metricIds);
20 }
21
22 private void writeMetricNamesHeaderFragment(final PrintWriter writer, final MetricId[] metricIds) {
23 for (int i = 0; i < metricIds.length; i++) {
24 writer.print(',');
25 writer.print(presentations.getShortPresentationName(metricIds[i]));
26 }
27 writer.println();
28 }
29 }
30