Class CopyrightMatcher

java.lang.Object
org.apache.rat.analysis.matchers.AbstractHeaderMatcher
org.apache.rat.analysis.matchers.CopyrightMatcher
All Implemented Interfaces:
IHeaderMatcher

public class CopyrightMatcher extends AbstractHeaderMatcher
Matches a typical Copyright header line only based on a regex pattern which allows for one (starting) year or year range, and a configurable copyright owner.

The matching is done case insensitive

Example supported Copyright header lines, using copyright owner "FooBar"
  • Copyright 2010 FooBar.
  • Copyright 2010-2012 FooBar.
  • copyright 2012 foobar

Note also that the copyright owner is appended to the regex pattern and so can support additional regex but also requires escaping where needed,
e.g. use "FooBar \\(www\\.foobar\\.com\\)" or "FooBar \\Q(www.foobar.com)\\E" to match "FooBar (www.foobar.com)"

The matcher also accepts "(C)", "(c)", and "©" in place of (or in addition to) the "Copyright" or "copyright" keyword

  • Constructor Details

    • CopyrightMatcher

      public CopyrightMatcher(String start, String end, String owner)
      Constructs the CopyrightMatcher with the specified start, stop and owner strings and a unique random id.
      Parameters:
      start - the start date for the copyright, may be null.
      end - the stop date for the copyright, may be null. May not be specified if start is not specified.
      owner - the owner of the copyright, may be null.
    • CopyrightMatcher

      public CopyrightMatcher(String id, String start, String end, String owner)
      Constructs the CopyrightMatcher with the specified start, stop and owner strings.
      Parameters:
      id - the id for the matcher.
      start - the start date for the copyright, may be null.
      end - the end date for the copyright, may be null. May not be specified if start is not specified.
      owner - the owner of the copyright. may be null.
  • Method Details

    • getStart

      public String getStart()
      Gets the start date of the copyright.
      Returns:
      the start date of the copyright or null if not set
    • getEnd

      public String getEnd()
      Gets the end date of the copyright.
      Returns:
      the end date of the copyright or null if not set
    • getOwner

      public String getOwner()
      Gets the owner of the copyright.
      Returns:
      the owner of the copyright or null if not set
    • matches

      public boolean matches(IHeaders headers)
      Description copied from interface: IHeaderMatcher
      Attempts to match text in the IHeaders instance.
      Parameters:
      headers - the representations of the headers to check
      Returns:
      true if the matcher matches the text, false otherwise.