Class CopyrightMatcher

All Implemented Interfaces:
IHeaderMatcher

public class CopyrightMatcher extends AbstractSimpleMatcher
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 stop, 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.
      stop - 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 stop, 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.
      stop - 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.
  • Method Details

    • doMatch

      protected boolean doMatch(String line)
      Description copied from class: AbstractSimpleMatcher
      Performs the actual match test.
      Specified by:
      doMatch in class AbstractSimpleMatcher
      Parameters:
      line - the line to check.
      Returns:
      true if the line matches, false otherwise.