Class SPDXMatcherFactory

java.lang.Object
org.apache.rat.analysis.matchers.SPDXMatcherFactory

public final class SPDXMatcherFactory extends Object
Defines a factory to produce matchers for an SPDX tag. SPDX tag is of the format SPDX-License-Identifier: short-name where short-name matches the regex pattern [A-Za-z0-9\.\-]+

SPDX identifiers are specified by the Software Package Data Exchange(R) also known as SPDX(R) project from the Linux foundation.

Each factory instance maintains its own matcher map and per-document match state (lastMatch, checked). In multi-threaded environments (e.g. parallel Maven builds), use newInstance() or a ThreadLocal<SPDXMatcherFactory> to obtain a per-thread factory instead of the shared INSTANCE.

See Also:
  • Field Details

    • INSTANCE

      @Deprecated public static final SPDXMatcherFactory INSTANCE
      Deprecated.
      Not thread-safe. Use newInstance() to create per-thread instances instead. Will be removed in 1.0.0.
      The shared instance of this factory.
  • Method Details

    • newInstance

      public static SPDXMatcherFactory newInstance()
      Creates a new SPDXMatcherFactory instance.

      Use this method to obtain a per-thread factory for multi-threaded environments instead of the shared INSTANCE.

      Returns:
      a new SPDXMatcherFactory instance.
    • create

      public SPDXMatcherFactory.Match create(String spdxId)
      Creates the SPDX matcher.
      Parameters:
      spdxId - the SPDX name to match.
      Returns:
      a SPDX matcher.