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 frontends is to create the configuration and invoke the Reporter.
  • Constructor Details

    • ReportConfiguration

      public ReportConfiguration()
      Constructor
  • Method Details

    • addSource

      public void addSource(File file)
      Adds a file as a source of files to scan. The file must be a text file that lists files to be included. File within the file must be in linux format with a "/" file separator.
      Parameters:
      file - the file to process.
    • addSource

      public void addSource(IReportable reportable)
      Adds a Reportable as a source of files to scan.
      Parameters:
      reportable - the reportable to process.
    • hasSource

      public boolean hasSource()
      Returns true if the configuration has any sources defined.
      Returns:
      true if the configuration has any sources defined.
    • getSources

      public IReportableListWalker.Builder getSources()
      Gets a builder initialized with any files specified as sources.
      Returns:
      a configured builder.
    • getGeneratedMatcher

      public IHeaderMatcher getGeneratedMatcher()
      Gets the matcher that matches generated text.
      Returns:
      the matcher that matches generated text.
    • getArchiveProcessing

      public ReportConfiguration.Processing getArchiveProcessing()
      Retrieves the archive processing type.
      Returns:
      The archive processing type.
    • setArchiveProcessing

      public void setArchiveProcessing(ReportConfiguration.Processing archiveProcessing)
      Sets the archive processing type. If not set will default to NOTIFICATION.
      Parameters:
      archiveProcessing - the type of processing archives should have.
    • getStandardProcessing

      public ReportConfiguration.Processing getStandardProcessing()
      Retrieves the archive processing type.
      Returns:
      The archive processing type.
    • setStandardProcessing

      public void setStandardProcessing(ReportConfiguration.Processing standardProcessing)
      Sets the archive processing type. If not set will default to NOTIFICATION.
      Parameters:
      standardProcessing - the type of processing archives should have.
    • 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.
    • listFamilies

      public void listFamilies(LicenseSetFactory.LicenseFilter filter)
      Set the level of license families that should be output in the XML document.
      Parameters:
      filter - the license families to list.
    • listFamilies

      public LicenseSetFactory.LicenseFilter listFamilies()
      Return the current filter that determines which families will be output in the XML document.
      Returns:
      the filter that defines the families to list.
    • listLicenses

      public void listLicenses(LicenseSetFactory.LicenseFilter filter)
      Set the level of licenses that should be output in the XML document.
      Parameters:
      filter - the licenses to list.
    • listLicenses

      public LicenseSetFactory.LicenseFilter listLicenses()
      Gets the selected license filter.
      Returns:
      the filter to limit license display.
    • setDryRun

      public void setDryRun(boolean state)
      Sets the dry run flag.
      Parameters:
      state - the state for the dry run flag.
    • isDryRun

      public boolean isDryRun()
      Returns the state of the dry run flag.
      Returns:
      the state of the dry run flag.
    • addExcludedCollection

      public void addExcludedCollection(StandardCollection collection)
      Excludes a StandardCollection of patterns.
      Parameters:
      collection - the StandardCollection to exclude.
      See Also:
    • addExcludedFileProcessor

      public void addExcludedFileProcessor(StandardCollection collection)
      Excludes the file processor defined in the StandardCollection.
      Parameters:
      collection - the StandardCollection to exclude.
      See Also:
    • addExcludedFilter

      public void addExcludedFilter(FileFilter fileFilter)
      Excludes files that match a FileFilter.
      Parameters:
      fileFilter - the file filter to match.
    • addExcludedMatcher

      public void addExcludedMatcher(DocumentNameMatcher matcher)
      Excludes files that match a DocumentNameMatcher.
      Parameters:
      matcher - the DocumentNameMatcher to match.
    • addExcludedPatterns

      public void addExcludedPatterns(Iterable<String> patterns)
      Excludes files that match the pattern.
      Parameters:
      patterns - the collection of patterns to exclude.
      See Also:
    • addIncludedCollection

      public void addIncludedCollection(StandardCollection collection)
      Adds the patterns from the standard collection as included patterns.
      Parameters:
      collection - the standard collection to include.
    • addIncludedFilter

      public void addIncludedFilter(FileFilter fileFilter)
      Adds the fileFilter to filter files that should be included, this overrides any exclusion of the same files.
      Parameters:
      fileFilter - the filter to identify files that should be included.
    • addIncludedPatterns

      public void addIncludedPatterns(Iterable<String> patterns)
      Add file patterns that are to be included. These patterns override any exclusion of the same files.
      Parameters:
      patterns - The iterable of Strings containing the patterns.
    • getDocumentExcluder

      public DocumentNameMatcher getDocumentExcluder(DocumentName baseDir)
      Get the DocumentNameMatcher that excludes files found in the directory tree..
      Parameters:
      baseDir - the DocumentName for the base directory.
      Returns:
      the DocumentNameMatcher for the base directory.
    • getStyleSheet

      public org.apache.commons.io.function.IOSupplier<InputStream> getStyleSheet()
      Gets the IOSupplier with the style sheet.
      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)
      Sets the style sheet.
      Parameters:
      styleSheet - the XSLT style sheet file 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.
    • 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:
    • 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:
    • 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()
      Gets a PrintWriter that wraps the output stream.
      Returns:
      A supplier for a PrintWriter that wraps the output stream.
      See Also:
    • 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.
      Returns:
      The ILicense implementation that was added.
    • 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.
    • 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.
    • getLicenseCategories

      public SortedSet<String> getLicenseCategories(LicenseSetFactory.LicenseFilter filter)
      Gets the SortedSet of approved license categories. Once a license has been removed from the approved list it cannot be re-added
      Parameters:
      filter - The LicenseFilter to filter the categories by.
      Returns:
      the Sorted set of approved license categories.
    • getLicenses

      public SortedSet<ILicense> getLicenses(LicenseSetFactory.LicenseFilter filter)
      Gets the SortedSet of approved license categories. Once a license has been removed from the approved list it cannot be re-added
      Parameters:
      filter - The LicenseFilter to filter the licenses by.
      Returns:
      the Sorted set of approved license categories.
    • getLicenseIds

      public SortedSet<String> getLicenseIds(LicenseSetFactory.LicenseFilter filter)
      Gets the SortedSet of approved license categories. Once a license has been removed from the approved list it cannot be re-added
      Parameters:
      filter - The LicenseFilter to filter the licenses by.
      Returns:
      the Sorted set of approved license categories.
    • addApprovedLicenseId

      public void addApprovedLicenseId(ILicense approvedLicense)
      Adds an ILicenseFamily to the list of approved licenses.
      Parameters:
      approvedLicense - the License to add.
    • addApprovedLicenseId

      public void addApprovedLicenseId(String licenseId)
      Adds a license family category (id) to the list of approved licenses
      Parameters:
      licenseId - the license id to add.
    • addApprovedLicenseIds

      public void addApprovedLicenseIds(Collection<String> approvedLicenseIds)
      Adds a collection of license family categories to the set of approved license names.
      Parameters:
      approvedLicenseIds - set of approved license IDs.
    • removeApprovedLicenseId

      public void removeApprovedLicenseId(String licenseId)
      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:
      licenseId - the license ID to add.
    • removeApprovedLicenseIds

      public void removeApprovedLicenseIds(Collection<String> licenseIds)
      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:
      licenseIds - the license IDs to remove.
    • 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:
    • 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:
    • isAddingLicensesForced

      public boolean isAddingLicensesForced()
      Gets the flag that determines if license headers are "forced" overwriting existing files. This value is ignored if RAT is not adding licenses.
      Returns:
      true if RAT is forcing the adding license headers.
      See Also:
    • isAddingLicenses

      public boolean isAddingLicenses()
      Gets the flag that determines if license headers should be added if missing.
      Returns:
      whether RAT should add missing license headers.
      See Also:
    • 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:
    • 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.
    • getClaimValidator

      public ClaimValidator getClaimValidator()
      Gets the ClaimValidator for the configuration.
      Returns:
      the ClaimValidator.
    • getLicenseSetFactory

      public LicenseSetFactory getLicenseSetFactory()
      Gets the enclosed LicenseSetFactory.
      Returns:
      the license set factory.
    • validate

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