Class LicenseInfoFactory

java.lang.Object
org.spdx.library.model.license.LicenseInfoFactory

public class LicenseInfoFactory
extends Object
Factory for creating SPDXLicenseInfo objects from a Jena model
Author:
Gary O'Neall
  • Field Details

  • Constructor Details

  • Method Details

    • getListedLicenseById

      public static SpdxListedLicense getListedLicenseById​(String licenseId) throws InvalidSPDXAnalysisException
      Parameters:
      licenseId - SPDX Listed License ID
      Returns:
      SPDX listed license or null if the ID is not in the SPDX license list
      Throws:
      InvalidSPDXAnalysisException
    • parseSPDXLicenseString

      public static AnyLicenseInfo parseSPDXLicenseString​(String licenseString, @Nullable IModelStore store, @Nullable String documentUri, @Nullable ModelCopyManager copyManager) throws InvalidLicenseStringException
      Parses a license string and converts it into a SPDXLicenseInfo object Syntax - A license set must start and end with a parenthesis "(" A conjunctive license set will have and AND after the first licenseInfo term A disjunctive license set will have an OR after the first licenseInfo term If there is no And or Or, then it is converted to a simple license type A space or tab must be used between license ID's and the keywords AND and OR A licenseID must NOT be "AND" or "OR"
      Parameters:
      licenseString - String conforming to the syntax
      store - Store containing any extractedLicenseInfos - if any extractedLicenseInfos by ID already exist, they will be used. If none exist for an ID, they will be added. If null, the default model store will be used.
      documentUri - Document URI for the document containing any extractedLicenseInfos - if any extractedLicenseInfos by ID already exist, they will be used. If none exist for an ID, they will be added. If null, the default model document URI will be used.
      copyManager - if non-null, allows for copying of any properties set which use other model stores or document URI's
      Returns:
      an SPDXLicenseInfo created from the string
      Throws:
      InvalidLicenseStringException
    • parseSPDXLicenseString

      public static AnyLicenseInfo parseSPDXLicenseString​(String licenseString) throws InvalidLicenseStringException
      Parses a license string and converts it into a SPDXLicenseInfo object Syntax - A license set must start and end with a parenthesis "(" A conjunctive license set will have and AND after the first licenseInfo term A disjunctive license set will have an OR after the first licenseInfo term If there is no And or Or, then it is converted to a simple license type A space or tab must be used between license ID's and the keywords AND and OR A licenseID must NOT be "AND" or "OR"
      Parameters:
      licenseString - String conforming to the syntax
      Returns:
      an SPDXLicenseInfo created from the string
      Throws:
      InvalidLicenseStringException
    • isSpdxListedLicenseId

      public static boolean isSpdxListedLicenseId​(String licenseID)
      Parameters:
      licenseID - case insensitive
      Returns:
      true if the licenseID belongs to an SPDX listed license
    • getSpdxListedLicenseIds

      public static List<String> getSpdxListedLicenseIds()
      Returns:
      Array of all SPDX listed license IDs
    • getLicenseListVersion

      public static String getLicenseListVersion()
      Returns:
      Version of the license list being used by the SPDXLicenseInfoFactory
    • isSpdxListedExceptionId

      public static boolean isSpdxListedExceptionId​(String id)
      Parameters:
      id - exception ID
      Returns:
      true if the exception ID is a supported SPDX listed exception
    • getListedExceptionById

      public static ListedLicenseException getListedExceptionById​(String id) throws InvalidSPDXAnalysisException
      Parameters:
      id -
      Returns:
      the standard SPDX license exception or null if the ID is not in the SPDX license list
      Throws:
      InvalidSPDXAnalysisException
    • listedLicenseIdCaseSensitive

      public static Optional<String> listedLicenseIdCaseSensitive​(String licenseId)
      Parameters:
      licenseId - case insensitive license ID
      Returns:
      the case sensitive license ID
    • listedExceptionIdCaseSensitive

      public static Optional<String> listedExceptionIdCaseSensitive​(String exceptionId)
      Parameters:
      exceptionId - case insensitive exception ID
      Returns:
      case sensitive ID