Interface IStatisticsExporter

All Known Implementing Classes:
CsvExporter, JsonExporter, XlsExporter

public interface IStatisticsExporter
The IStatisticsExporter interface defines the capability to export statistical data related to translations into a specific format and save it to a given path. Implementations of this interface are responsible for handling the serialization of statistical data provided by a StatisticsProvider, for a specified set of languages and metrics, into a format suitable for consumption by external systems or for reporting purposes.

The export process is defined by the single method export, which takes a path to save the exported data, a statistics provider that supplies the data to be exported, a collection of languages that specifies the scope of translation statistics to be included, and a collection of metrics that defines the specific statistical measurements to be exported.

This interface is agnostic to the specific format of the export (such as CSV, JSON, or XML), leaving the implementation details to concrete classes. It enables flexibility in exporting translation statistics across various formats by simply implementing this interface for each desired format.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    export(Path path, StatisticsProvider provider, Collection<TranslateLanguage> languages, Collection<Metric> metrics)
    Exports statistical data related to translations for the specified languages and metrics, using the data provided by the given StatisticsProvider, and saves the exported data to the specified path.
    default List<Pair<org.eclipse.core.runtime.IPath,Statistics>>
    sortStatisticsByPath(Iterator<Pair<org.eclipse.core.runtime.IPath,Statistics>> iterator)
    Sorts a collection of key-value pairs (IPath, Statistics) by the string representation of the key (IPath.toString()), specifically for organizing statistics associated with paths in ascending order.
  • Method Details

    • export

      void export(Path path, StatisticsProvider provider, Collection<TranslateLanguage> languages, Collection<Metric> metrics) throws IOException
      Exports statistical data related to translations for the specified languages and metrics, using the data provided by the given StatisticsProvider, and saves the exported data to the specified path.
      Parameters:
      path - The Path where the exported data should be saved. This path must be accessible and writable by the implementation. Must not be null.
      provider - The StatisticsProvider that supplies the statistical data to be exported. Must not be null.
      languages - A Collection of TranslateLanguage objects specifying the languages for which statistics should be exported. If empty, the implementation may decide to export statistics for all available languages. Must not be null.
      metrics - A Collection of Metric objects defining the specific statistical measurements to be included in the export. If empty, the implementation may decide to include all available metrics. Must not be null.
      Throws:
      IOException - if an I/O error occurs during the export process. Implementations should ensure to handle such exceptions appropriately.
    • sortStatisticsByPath

      default List<Pair<org.eclipse.core.runtime.IPath,Statistics>> sortStatisticsByPath(Iterator<Pair<org.eclipse.core.runtime.IPath,Statistics>> iterator)
      Sorts a collection of key-value pairs (IPath, Statistics) by the string representation of the key (IPath.toString()), specifically for organizing statistics associated with paths in ascending order.
      Parameters:
      iterator - An iterator providing the collection of key-value pairs to be sorted. Must not be null.
      Returns:
      A new List containing the sorted key-value pairs. Must not be null.