Class LicenseResolver

java.lang.Object
org.cyclonedx.util.LicenseResolver

public final class LicenseResolver extends Object
  • Field Details

  • Constructor Details

    • LicenseResolver

      private LicenseResolver()
      Private constructor.
  • Method Details

    • resolve

      public static LicenseChoice resolve(String licenseString)
      Attempts to resolve the specified license string via SPDX license identifier and expression parsing first. If SPDX resolution is not successful, the method will attempt fuzzy matching.
      Parameters:
      licenseString - the license string to resolve
      Returns:
      a LicenseChoice object if resolution was successful, or null if unresolved
    • resolve

      public static LicenseChoice resolve(String licenseString, boolean includeLicenseText)
      Attempts to resolve the specified license string via SPDX license identifier and expression parsing first. If SPDX resolution is not successful, the method will attempt fuzzy matching.
      Parameters:
      licenseString - the license string to resolve
      includeLicenseText - specifies is the resolved license will include the entire text of the license
      Returns:
      a LicenseChoice object if resolution was successful, or null if unresolved
    • resolve

      static LicenseChoice resolve(String licenseString, boolean includeLicenseText, com.fasterxml.jackson.databind.ObjectMapper mapper)
    • resolve

      public static LicenseChoice resolve(String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings)
      Attempts to resolve the specified license string via SPDX license identifier and expression parsing first. If SPDX resolution is not successful, the method will attempt fuzzy matching.
      Parameters:
      licenseString - the license string to resolve
      licenseTextSettings - specifies settings regarding the entire text of the resolved license
      Returns:
      a LicenseChoice object if resolution was successful, or null if unresolved
    • resolve

      static LicenseChoice resolve(String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings, com.fasterxml.jackson.databind.ObjectMapper mapper)
    • resolveLicenseString

      private static LicenseChoice resolveLicenseString(String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings, com.fasterxml.jackson.databind.ObjectMapper mapper) throws IOException
      Given an SPDX license ID or expression, this method will resolve the license(s) and return a LicenseChoice object.
      Parameters:
      licenseString - the license string to resolve
      licenseTextSettings - specifies settings regarding the entire text of the resolved license
      mapper - is to provide a Jackson ObjectMapper
      Returns:
      a LicenseChoice object if resolved, or null
      Throws:
      IOException - an exception while parsing the license string
    • resolveFuzzyMatching

      private static LicenseChoice resolveFuzzyMatching(String licenseString, LicenseResolver.LicenseTextSettings licenseTextSettings, com.fasterxml.jackson.databind.ObjectMapper mapper) throws IOException
      Attempts to perform high-confidence license resolution with unstructured text as input.
      Parameters:
      licenseString - the license string (not the actual license text)
      licenseTextSettings - specifies settings regarding the entire text of the resolved license
      mapper - is to provide a Jackson ObjectMapper
      Returns:
      a LicenseChoice object if resolved, otherwise null
      Throws:
      IOException
    • urlNormalize

      private static String urlNormalize(String input)
    • createLicenseChoice

      private static LicenseChoice createLicenseChoice(String licenseId, String primaryLicenseUrl, boolean isDeprecatedLicenseId, LicenseResolver.LicenseTextSettings licenseTextSettings) throws IOException
      Throws:
      IOException