See: Description
| Class | Description | 
|---|---|
| DataExportConfiguration | Encapsulates the output configuration settings for data export. | 
| DataExporter | Exports tabular data in various formats. | 
| ExportFormatter | Base class for data export formatters. | 
| ExportFormatterFactory | Knows all available file export formats by their extensions and creates
 formatters for them. | 
| OverwriteConfirmation | Confirmation to overwrite existing files. | 
| Enum | Description | 
|---|---|
| DataExportConfiguration.QuotingStrategy | Enumerates the quoting strategies for text-based output file formats such
 as CSV. | 
Tutorial - exporting metric data and rule violations
The following code snippets take you to the steps of exporting measurement data
provided through the interface DataTables. 
import sdmetrics.app.ConsoleMessageHandler; import sdmetrics.app.MetricData; import sdmetrics.app.RuleData; import sdmetrics.output.DataExportConfiguration; import sdmetrics.output.DataExporter; import sdmetrics.output.ExportFormatter; import sdmetrics.output.ExportFormatterFactory; import sdmetrics.output.OverwriteConfirmation;
com.sdmetrics.app.
MetricData metrics = ...; // Metric data, need not be pre-calculated RuleData rules = ...; // Rule violations, must already have been checked
DataExportConfigurationconfig = new DataExportConfiguration(); ConsoleMessageHandler msgHandler = new ConsoleMessageHandler();DataExporterexporter = new DataExporter(msgHandler, config);
ExportFormatter textFormat =ExportFormatterFactory.getFormatter("txt"); exporter.export(metrics, "sampleMetrics", textFormat);
config.setSingleOutputFile(false);
config.setEncoding("UTF-8");
config.setOverwriteConfirmer(new ConsoleOverwriteConfirmation());
ExportFormatter htmlFormat = ExportFormatterFactory.getFormatter("html");
exporter.export(rules, "sampleRules", htmlFormat);
Note that class ConsoleOverwriteConfirmation is not provided by SDMetrics.
The following implementation prompts the user at the console, and offers "no/yes/yes to all"
options to confirm file overwrites.
class ConsoleOverwriteConfirmation extends OverwriteConfirmation {
   boolean yesToAllGiven = false;
   public boolean okToOverwrite(String fileName, boolean oneFile) {
      if (!new java.io.File(fileName).exists() || yesToAllGiven)
         return true;
      System.out.println("OK to overwrite file " + fileName + "?");
      String reply = System.console().readLine(
               "[N] for no, [Y] for yes%s",
               (oneFile ? ": " : ", [A] for yes to all: "));
               
      if ("Y".equalsIgnoreCase(reply))
         return true;
      if (!oneFile && "A".equalsIgnoreCase(reply)) {
         yesToAllGiven = true;
         return true;
      }
      return false;
   }
 }