Interface FileHeaderRewriter

All Known Subinterfaces:
StandardFileHeaderRewriter

public interface FileHeaderRewriter
Represents a way to change the file header to a specific text.

All implementations should be Serializable or a valid @Nested property value, as they will be used in task inputs.

  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Detects the line ending used in the given content, from either LF or CRLF.
    rewriteHeader(String fileContent, String headerText)
    Rewrites the header of the given file content to the specified header text, if needed.
  • Method Details

    • detectLineEnding

      static String detectLineEnding(String content)
      Detects the line ending used in the given content, from either LF or CRLF. If multiple line endings are used, an error is thrown. If no line endings are found, System.lineSeparator() is returned.
      Parameters:
      content - the content to analyze
      Returns:
      the detected line ending
      Throws:
      IllegalArgumentException - if multiple line endings are detected
    • rewriteHeader

      @Nullable ModificationWriter rewriteHeader(String fileContent, String headerText)
      Rewrites the header of the given file content to the specified header text, if needed.
      Parameters:
      fileContent - the content of the file
      headerText - the header text to apply
      Returns:
      a function that writes the modified content to an Appendable if the content needs to be modified, or null otherwise