Class LineDeletion

java.lang.Object
uno.anahata.asi.toolkit.resources.text.lines.AbstractLineEdit
uno.anahata.asi.toolkit.resources.text.lines.LineDeletion

public class LineDeletion extends AbstractLineEdit
A safety-first deletion operation that removes a contiguous range of lines.

This implementation requires an explicit expectedCount to act as a checksum, preventing accidental mass deletions due to coordinate drift or misinterpretation of the file structure.

  • Field Details

    • startLine

      private int startLine
      The 1-based line number where the deletion sequence begins (Inclusive).
    • endLine

      private int endLine
      The 1-based line number where the deletion sequence ends (Inclusive).
    • expectedCount

      private int expectedCount
      The number of lines expected to be removed.

      This serves as a critical validation checkpoint; if the actual range size does not match this value, the operation will fail to protect file integrity.

  • Constructor Details

    • LineDeletion

      public LineDeletion()
  • Method Details

    • apply

      public void apply(List<String> lines) throws AgiToolException
      Applies this edit to a mutable list of lines.

      Performs range validation and checksum verification before removing lines from the provided list.

      Specified by:
      apply in class AbstractLineEdit
      Parameters:
      lines - The current lines of the file.
      Throws:
      AgiToolException - if indices are out of bounds or validation fails.
    • getSortLine

      public int getSortLine()
      Returns the 1-based line number where this operation starts. Used for sorting updates before application.

      Returns the start line of the range to facilitate descending sort during the application phase.

      Specified by:
      getSortLine in class AbstractLineEdit
      Returns:
      the start line.