Class ReportConfiguration

java.lang.Object
org.apache.rat.ReportConfiguration

public class ReportConfiguration extends Object
A configuration object is used by the front end to invoke the Reporter. The sole purpose of the front ends is to create the configuration and invoke the Reporter.
  • Constructor Details

    • ReportConfiguration

      public ReportConfiguration(Log log)
      Constructor
      Parameters:
      log - The Log implementation that messages will be written to.
  • Method Details

    • getLog

      public Log getLog()
      Retrieves the Log that was provided in the constructor.
      Returns:
      the Log for the system.
    • logFamilyCollisions

      public void logFamilyCollisions(Log.Level level)
      Set the log level for reporting collisions in the set of license families.

      NOTE: should be set before licenses or license families are added.

      Parameters:
      level - The log level to use.
    • familyDuplicateOption

      public void familyDuplicateOption(ReportingSet.Options state)
      Sets the reporting option for duplicate license families.
      Parameters:
      state - The ReportingSet.Option to use for reporting.
    • logLicenseCollisions

      public void logLicenseCollisions(Log.Level level)
      Sets the log level for reporting license collisions.
      Parameters:
      level - The log level.
    • licenseDuplicateOption

      public void licenseDuplicateOption(ReportingSet.Options state)
      Sets the reporting option for duplicate licenses.
      Parameters:
      state - the ReportingSt.Option to use for reporting.
    • getInputFileFilter

      public FilenameFilter getInputFileFilter()
      Returns:
      The filename filter for the potential input files.
    • setInputFileFilter

      public void setInputFileFilter(FilenameFilter inputFileFilter)
      Parameters:
      inputFileFilter - the filename filter to filter the input files.
    • getDirectoryFilter

      public org.apache.commons.io.filefilter.IOFileFilter getDirectoryFilter()
    • setDirectoryFilter

      public void setDirectoryFilter(org.apache.commons.io.filefilter.IOFileFilter directoryFilter)
    • addDirectoryFilter

      public void addDirectoryFilter(org.apache.commons.io.filefilter.IOFileFilter directoryFilter)
    • getReportable

      public IReportable getReportable()
      Returns:
      the thing being reported on.
    • setReportable

      public void setReportable(IReportable reportable)
      Parameters:
      reportable - the thing being reported on.
    • getStyleSheet

      public org.apache.commons.io.function.IOSupplier<InputStream> getStyleSheet()
      Returns:
      the Supplier of the InputStream that is the XSLT style sheet to style the report with.
    • setStyleSheet

      public void setStyleSheet(org.apache.commons.io.function.IOSupplier<InputStream> styleSheet)
      Sets the style sheet for custom processing. The IOSupplier may be called multiple times, so the input stream must be able to be opened and closed multiple times.
      Parameters:
      styleSheet - the XSLT style sheet to style the report with.
    • setFrom

      public void setFrom(Defaults defaults)
      Adds the licenses and approved licenses from the defaults object to the configuration. Side effect: if the report should be styled and no style sheet has been set the plain stylesheet from the defaults will be used.
      Parameters:
      defaults - The defaults to set.
    • setStyleSheet

      public void setStyleSheet(File styleSheet)
      Parameters:
      styleSheet - the XSLT style sheet to style the report with.
    • setStyleSheet

      public void setStyleSheet(URI styleSheet)
      Sets the style sheet for custom processing. The stylesheet may be opened multiple times so the URI must be capable of being opened multiple times.
      Parameters:
      styleSheet - the URI of the XSLT style sheet to style the report with.
    • setStyleSheet

      public void setStyleSheet(URL styleSheet)
      Sets the style sheet for custom processing. The stylesheet may be opened multiple times so the URL must be capable of being opened multiple times.
      Parameters:
      styleSheet - the URL of the XSLT style sheet to style the report with.
    • isStyleReport

      public boolean isStyleReport()
      Returns:
      true if the XML report should be styled.
    • setStyleReport

      public void setStyleReport(boolean styleReport)
      Parameters:
      styleReport - specifies whether the XML report should be styled.
    • setOut

      public void setOut(org.apache.commons.io.function.IOSupplier<OutputStream> out)
      Sets the supplier for the output stream. The supplier may be called multiple times to provide the stream. Suppliers should prepare streams that are appended to and that can be closed. If an OutputStream should not be closed consider wrapping it in a NoCloseOutputStream
      Parameters:
      out - The OutputStream supplier that provides the output stream to write the report to. A null value will use System.out.
      See Also:
      ReportConfiguration.NoCloseOutputStream
    • setOut

      public void setOut(File file)
      Sets the OutputStream supplier to use the specified file. The file may be opened and closed several times. File is deleted first and then may be repeatedly opened in append mode.
      Parameters:
      file - The file to create the supplier with.
      See Also:
      setOut(IOSupplier)
    • getOutput

      public org.apache.commons.io.function.IOSupplier<OutputStream> getOutput()
      Returns the output stream supplier. If no stream has been set returns a supplier for System.out.
      Returns:
      The supplier of the output stream to write the report to.
    • getWriter

      public org.apache.commons.io.function.IOSupplier<PrintWriter> getWriter()
      Returns:
      A supplier for a PrintWriter that wraps the output stream.
      See Also:
      getOutput()
    • addLicense

      public void addLicense(ILicense license)
      Adds a license to the list of licenses. Does not add the license to the list of approved licenses.
      Parameters:
      license - The license to add to the list of licenses.
    • addLicense

      public ILicense addLicense(ILicense.Builder builder)
      Adds a license to the list of licenses. Does not add the license to the list of approved licenses.
      Parameters:
      builder - The license builder to build and add to the list of licenses.
    • addLicenses

      public void addLicenses(Collection<ILicense> licenses)
      Adds multiple licenses to the list of licenses. Does not add the licenses to the list of approved licenses.
      Parameters:
      licenses - The licenses to add.
    • addLicensesIfNotPresent

      public void addLicensesIfNotPresent(Collection<ILicense> licenses)
      Adds multiple licenses to the list of licenses. Does not add the licenses to the list of approved licenses.
      Parameters:
      licenses - The licenses to add.
    • addFamily

      public void addFamily(ILicenseFamily family)
      Adds a license family to the list of families. Does not add the family to the list of approved licenses.
      Parameters:
      family - The license family to add to the list of license families.
    • addFamily

      public void addFamily(ILicenseFamily.Builder builder)
      Adds a license family to the list of families. Does not add the family to the list of approved licenses.
      Parameters:
      builder - The licenseFamily.Builder to build and add to the list of licenses.
    • addFamilies

      public void addFamilies(Collection<ILicenseFamily> families)
      Adds multiple families to the list of license families. Does not add the licenses to the list of approved licenses.
      Parameters:
      families - The license families to add.
    • addApprovedLicenseCategory

      public void addApprovedLicenseCategory(ILicenseFamily approvedILicenseFamily)
      Adds an ILicenseFamily to the list of approved licenses.
      Parameters:
      approvedILicenseFamily - the LicenseFamily to add.
    • addApprovedLicenseCategory

      public void addApprovedLicenseCategory(String familyCategory)
      Adds a license family category (id) to the list of approved licenses
      Parameters:
      familyCategory - the category to add.
    • addApprovedLicenseCategories

      public void addApprovedLicenseCategories(Collection<String> approvedLicenseCategories)
      Adds a collection of license family categories to the set of approved license names.
      Parameters:
      approvedLicenseCategories - set of approved license categories.
    • removeApprovedLicenseCategory

      public void removeApprovedLicenseCategory(String familyCategory)
      Adds a license family category to the list of approved licenses. Once a license has been removed from the approved list it cannot be re-added
      Parameters:
      familyCategory - the category to add.
    • removeApprovedLicenseCategories

      public void removeApprovedLicenseCategories(Collection<String> familyCategory)
      Removes a license family category from the list of approved licenses. Once a license has been removed from the approved list it cannot be re-added
      Parameters:
      familyCategory - the family category to remove.
    • getApprovedLicenseCategories

      public SortedSet<String> getApprovedLicenseCategories()
      Gets the SortedSet of approved license categories. Once a license has been removed from the approved list it cannot be re-added
      Returns:
      the Sorted set of approved license categories.
    • getCopyrightMessage

      public String getCopyrightMessage()
      Returns the optional license copyright being added if RAT is adding headers. This value is ignored, if no license headers are added.
      Returns:
      the optional copyright message.
      See Also:
      isAddingLicenses()
    • setCopyrightMessage

      public void setCopyrightMessage(String copyrightMessage)
      Sets the optional copyright message used if RAT is adding license headers. This value is ignored, if no license headers are added.
      Parameters:
      copyrightMessage - message to set.
      See Also:
      isAddingLicenses()
    • isAddingLicensesForced

      public boolean isAddingLicensesForced()
      This value is ignored if RAT is not adding licenses.
      Returns:
      true if RAT is forcing the adding license headers.
      See Also:
      isAddingLicenses()
    • isAddingLicenses

      public boolean isAddingLicenses()
      Returns:
      whether RAT should add missing license headers.
      See Also:
      isAddingLicensesForced(), getCopyrightMessage()
    • setAddLicenseHeaders

      public void setAddLicenseHeaders(AddLicenseHeaders addLicenseHeaders)
      Sets whether RAT should enable, disable, or force the adding of license headers.
      Parameters:
      addLicenseHeaders - enables/disables or forces adding of licenses headers.
      See Also:
      isAddingLicenses(), setCopyrightMessage(String)
    • getLicenses

      public SortedSet<ILicense> getLicenses(LicenseSetFactory.LicenseFilter filter)
      Gets a set Licenses of depending on the filter if filter is set:
      • all - All licenses will be returned.
      • approved - Only approved licenses will be returned
      • none - No licenses will be returned
      Parameters:
      filter - The license filter.
      Returns:
      The set of defined licenses.
    • getLicenseFamilies

      public SortedSet<ILicenseFamily> getLicenseFamilies(LicenseSetFactory.LicenseFilter filter)
      Gets a sorted set of ILicenseFamily objects based on filter. if filter is set:
      • all - All licenses families will be returned.
      • approved - Only approved license families will be returned
      • none - No license families will be returned
      Parameters:
      filter - The license filter.
      Returns:
      The set of defined licenses.
    • validate

      public void validate(Consumer<String> logger)
      Validates that the configuration is valid.
      Parameters:
      logger - String consumer to log warning messages to.