Class AbstractLicenseAppender

java.lang.Object
org.apache.rat.annotation.AbstractLicenseAppender
Direct Known Subclasses:
ApacheV2LicenseAppender

public abstract class AbstractLicenseAppender extends Object
Add a license header to a document. This appender does not check for the existence of an existing license header, it is assumed that either a second license header is intentional or that there is no license header present already.
  • Constructor Details

    • AbstractLicenseAppender

      public AbstractLicenseAppender(Log log)
      Constructor
      Parameters:
      log - The log to use.
  • Method Details

    • append

      public void append(File document) throws IOException
      Append the default license header to the supplied document.
      Parameters:
      document - document to append to.
      Throws:
      IOException - if there is a problem while reading or writing the file
    • getType

      protected int getType(File document)
      Detect the type of document.
      Parameters:
      document - to retrieve type from.
      Returns:
      not null TODO use existing mechanism to detect the type of a file and record it in the report output, thus we will not need this duplication here.
    • setForce

      public void setForce(boolean force)
      Set the force flag on this appender. If this flag is set to true then files will be modified directly, otherwise new files will be created alongside the existing files.
      Parameters:
      force - force flag.
    • getLicenseHeader

      public abstract String getLicenseHeader(File document)
      Parameters:
      document - document to extract from.
      Returns:
      Get the license header of a document.
    • getFirstLine

      protected String getFirstLine(int type)
      Get the first line of the license header formatted for the given type of file.
      Parameters:
      type - the type of file, see the TYPE_* constants
      Returns:
      not null
    • getLastLine

      protected String getLastLine(int type)
      Get the last line of the license header formatted for the given type of file.
      Parameters:
      type - the type of file, see the TYPE_* constants
      Returns:
      not null
    • getLine

      protected String getLine(int type, String content)
      Get a line of the license header formatted for the given type of file.
      Parameters:
      type - the type of file, see the TYPE_* constants
      content - the content for this line
      Returns:
      not null