Class CsvNavigateCommand

java.lang.Object
com.streamconverter.command.AbstractStreamCommand
com.streamconverter.command.impl.csv.CsvNavigateCommand
All Implemented Interfaces:
IStreamCommand

CSV Navigate Command Class

This class implements command for targeted CSV transformation using column selectors. It identifies specific columns using column names or indices and applies IRule transformations to those columns while preserving the overall CSV structure.

  • Method Details

    • create

      @Deprecated public static CsvNavigateCommand create(String columnSelector, IRule rule)
      Deprecated.
      Factory method for creating a CSV navigation command with explicit rule specification. This method makes the intention explicit: extract data from the specified column and apply the given transformation rule.
      Parameters:
      columnSelector - the column name or index to select (e.g., "name", "2")
      rule - the transformation rule to apply to selected column data
      Returns:
      a CsvNavigateCommand that extracts the specified column with the given rule
      Throws:
      IllegalArgumentException - if rule is null
    • create

      public static CsvNavigateCommand create(CSVPath columnSelector, IRule rule)
      Factory method for creating a CSV navigation command with typed column selector and rule.
      Parameters:
      columnSelector - the typed CSVPath to select column
      rule - the transformation rule to apply to selected column data
      Returns:
      a CsvNavigateCommand that extracts the specified column with the given rule
      Throws:
      IllegalArgumentException - if columnSelector or rule is null
    • create

      public static CsvNavigateCommand create(TreePath treePath, IRule rule)
      Factory method for creating a CSV navigation command with TreePath compatibility.
      Parameters:
      treePath - the TreePath representing column selector
      rule - the transformation rule to apply to selected column data
      Returns:
      a CsvNavigateCommand that extracts the specified column with the given rule
      Throws:
      IllegalArgumentException - if treePath or rule is null
    • execute

      public void execute(InputStream inputStream, OutputStream outputStream) throws IOException
      Description copied from class: AbstractStreamCommand
      Executes the command on the provided input stream and writes the result to the output stream.
      Specified by:
      execute in interface IStreamCommand
      Specified by:
      execute in class AbstractStreamCommand
      Parameters:
      inputStream - The input stream to read data from.
      outputStream - The output stream to write data to.
      Throws:
      IOException - If an I/O error occurs during the execution of the command.