Class AbstractSimpleMatcher

java.lang.Object
org.apache.rat.analysis.matchers.AbstractHeaderMatcher
org.apache.rat.analysis.matchers.AbstractSimpleMatcher
All Implemented Interfaces:
IHeaderMatcher
Direct Known Subclasses:
CopyrightMatcher, FullTextMatcher, SimpleRegexMatcher, SimpleTextMatcher, SPDXMatcherFactory.Match

public abstract class AbstractSimpleMatcher extends AbstractHeaderMatcher
An abstract IHeaderMatcher that does simple matching. Implementations need to implement the doMatch(String) method to perform the actual matching. All handling of the State is managed by this class. By default the finalizeState() method will convert State.i to State.f.
  • Constructor Details

    • AbstractSimpleMatcher

      protected AbstractSimpleMatcher(String id)
      Constructs the AbstractSimpleMatcher with the specified id. If the id is null or an empty string a unique random id will be generated.
      Parameters:
      id - the Id to use. May be null.
  • Method Details

    • doMatch

      protected abstract boolean doMatch(String line)
      Performs the actual match test.
      Parameters:
      line - the line to check.
      Returns:
      true if the line matches, false otherwise.
    • matches

      public final IHeaderMatcher.State matches(String line)
      Description copied from interface: IHeaderMatcher
      Attempts to match line and returns the State after the match is attempted.
      Parameters:
      line - next line of text, not null
      Returns:
      the new state after the matching was attempted.
    • reset

      public void reset()
      Description copied from interface: IHeaderMatcher
      Resets this state State.i. If text is being cached this method should clear that cache.
    • finalizeState

      public IHeaderMatcher.State finalizeState()
      Description copied from interface: IHeaderMatcher
      Gets the final state for this matcher. This is called after the EOF on the input. At this point there should be no matchers in an State.i state.
    • currentState

      public final IHeaderMatcher.State currentState()
      Description copied from interface: IHeaderMatcher
      Gets the the current state of the matcher. All matchers should be in State.i at the start.
      Returns:
      the current state of the matcher.