Class SourceTable
java.lang.Object
org.sentrysoftware.metricshub.engine.strategy.source.SourceTable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncsvToTable(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]]static SourceTableempty()Creates an emptySourceTableinstance.booleanisEmpty()Whether the current source table is empty or notlineToList(String line, String separator) Transforms a line of CSV-formatted data to a list.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.static StringtableToCsv(List<List<String>> table, String separator, boolean replaceSeparator)
-
Constructor Details
-
SourceTable
public SourceTable()
-
-
Method Details
-
tableToCsv
public static String tableToCsv(List<List<String>> table, String separator, boolean replaceSeparator) - Parameters:
table- The table result we wish to parseseparator- The cells separator on each linereplaceSeparator- Whether we should replace the separator by comma- Returns:
Stringvalue
-
csvToTable
Return the List representation of the CSV String table : a1,b1,c1, a2,b2,c2, => [[a1,b1,c2],[a1,b1,c1]] -
lineToList
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
Creates an emptySourceTableinstance.- Returns:
- An empty
SourceTableinstance.
-
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 informationconnectorId- The connector identifier used to retrieveSourceTablefrom the connector namespace.telemetryManager- The instance wrapping the host properties where the connector namespace is located.- Returns:
Optionalinstance ofSourceTable
-