java.lang.Object
org.sentrysoftware.metricshub.engine.strategy.source.SourceTable

public class SourceTable extends Object
The SourceTable class represents a table of data obtained from monitor sources. It includes methods for transforming the table to and from CSV format and performing other related operations.
  • Constructor Details

    • SourceTable

      public SourceTable()
  • Method Details

    • tableToCsv

      public static String tableToCsv(List<List<String>> table, String separator, boolean replaceSeparator)
      Transform the List table to a String representation [[a1,b1,c2],[a1,b1,c1]] => a1,b1,c1, a2,b2,c2,
      Parameters:
      table - The table result we wish to parse
      separator - The cells separator on each line
      replaceSeparator - Whether we should replace the separator by comma
      Returns:
      String value
    • csvToTable

      public static List<List<String>> csvToTable(String csvTable, String separator)
      Return the List representation of the CSV String table : a1,b1,c1, a2,b2,c2, => [[a1,b1,c2],[a1,b1,c1]]
      Parameters:
      csvTable - The CSV table we wish to parse
      separator - The cells separator
      Returns:
      List of List table
    • lineToList

      public static List<String> lineToList(String line, String separator)
      Transforms a line of CSV-formatted data to a list.

      a1,b1,c1, => [ a1, b1, c1 ]

      Parameters:
      line - The CSV-formatted line to be transformed.
      separator - The separator between cells.
      Returns:
      The list of strings representing the line.
    • empty

      public static SourceTable empty()
      Creates an empty SourceTable instance.
      Returns:
      An empty SourceTable instance.
    • isEmpty

      public boolean isEmpty()
      Whether the current source table is empty or not
      Returns:
      boolean value
    • lookupSourceTable

      public static Optional<SourceTable> lookupSourceTable(String sourceKey, String connectorId, TelemetryManager telemetryManager)
      Find the source table instance from the connector namespace.
      If we have a hard-coded source then we will create a source wrapping the csv input.
      Parameters:
      sourceKey - The reference of the source or hard-coded source information
      connectorId - The connector identifier used to retrieve SourceTable from the connector namespace.
      telemetryManager - The instance wrapping the host properties where the connector namespace is located.
      Returns:
      Optional instance of SourceTable