Class FilterResultHelper

java.lang.Object
org.sentrysoftware.metricshub.engine.common.helpers.FilterResultHelper

public class FilterResultHelper extends Object
Utility class for filtering and selecting columns in a list of lines.
  • Constructor Details

    • FilterResultHelper

      public FilterResultHelper()
  • Method Details

    • filterLines

      public static List<String> filterLines(@NonNull @NonNull List<String> lines, Integer removeHeader, Integer removeFooter, String excludeRegExp, String keepOnlyRegExp)
      Filter the lines:
      • In removing the header if exists: all the lines from start to removeHeader number.
      • In removing the Footer if exists: all the removeFooter number lines from the end.
      • In removing all the lines matching to the excludeRegExp if exist
      • In keeping only the lines matching to the keepOnlyRegExp if exist
      Parameters:
      lines - The lines to be filtered. (mandatory)
      removeHeader - The number of lines to ignored from the start.
      removeFooter - The number of lines to ignored from the end.
      excludeRegExp - The PSL regexp to exclude lines.
      keepOnlyRegExp - The PSL regexp for lines to keep.
      Returns:
      The filterd lines.
    • selectedColumns

      public static List<String> selectedColumns(@NonNull @NonNull List<String> lines, String separators, String selectColumns)
      Select the columns in the lines. Extract separators and split each line with these separators keep only values (from the split result) which index matches with the selected column list
      Parameters:
      lines - The lines (mandatory)
      separators - The separators
      selectColumns - The list of the selected columns position.
      Returns:
      The lines with the selected columns.