Class LicenseInfoFactory


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static String getLicenseListVersion()  
      static org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException getListedExceptionById​(String id)  
      static org.spdx.library.model.v2.license.ListedLicenseException getListedExceptionV2ById​(String id)  
      static org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicense getListedLicenseById​(String licenseId)  
      static org.spdx.library.model.v2.license.SpdxListedLicense getListedLicenseByIdCompatV2​(String licenseId)  
      static org.spdx.library.model.v3_0_1.core.CreationInfo getListedLicenseCreationInfo()  
      static List<String> getSpdxListedLicenseIds()  
      static boolean isSpdxListedExceptionId​(String id)  
      static boolean isSpdxListedLicenseId​(String licenseID)  
      static Optional<String> listedExceptionIdCaseSensitive​(String exceptionId)  
      static Optional<String> listedLicenseIdCaseSensitive​(String licenseId)  
      static org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo parseSPDXLicenseString​(String licenseString)
      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"
      static org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo parseSPDXLicenseString​(String licenseString, org.spdx.storage.IModelStore store, String customLicensePrefix, org.spdx.core.IModelCopyManager copyManager, List<org.spdx.library.model.v3_0_1.core.DictionaryEntry> customIdToUri)
      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"
      static org.spdx.library.model.v2.license.AnyLicenseInfo parseSPDXLicenseStringCompatV2​(String licenseString)
      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"
      static org.spdx.library.model.v2.license.AnyLicenseInfo parseSPDXLicenseStringCompatV2​(String licenseString, org.spdx.storage.IModelStore store, String documentUri, org.spdx.core.IModelCopyManager copyManager)
      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"
    • Constructor Detail

      • LicenseInfoFactory

        public LicenseInfoFactory()
    • Method Detail

      • getListedLicenseById

        public static org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicense getListedLicenseById​(String licenseId)
                                                                                                  throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        licenseId - SPDX Listed License ID
        Returns:
        SPDX listed license or null if the ID is not in the SPDX license list
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on errors getting license data
      • getListedLicenseByIdCompatV2

        public static org.spdx.library.model.v2.license.SpdxListedLicense getListedLicenseByIdCompatV2​(String licenseId)
                                                                                                throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        licenseId - SPDX Listed License ID
        Returns:
        SPDX listed license in SPDX spec version 2.X format or null if the ID is not in the SPDX license list
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on errors getting license data
      • parseSPDXLicenseStringCompatV2

        public static org.spdx.library.model.v2.license.AnyLicenseInfo parseSPDXLicenseStringCompatV2​(String licenseString,
                                                                                                      @Nullable
                                                                                                      org.spdx.storage.IModelStore store,
                                                                                                      @Nullable
                                                                                                      String documentUri,
                                                                                                      @Nullable
                                                                                                      org.spdx.core.IModelCopyManager copyManager)
                                                                                               throws org.spdx.library.model.v2.license.InvalidLicenseStringException,
                                                                                                      org.spdx.core.DefaultStoreNotInitialized
        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:
        org.spdx.library.model.v2.license.InvalidLicenseStringException - if the license string is not valid
        org.spdx.core.DefaultStoreNotInitialized - if the default model store is not initialized
      • parseSPDXLicenseString

        public static org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo parseSPDXLicenseString​(String licenseString,
                                                                                                          @Nullable
                                                                                                          org.spdx.storage.IModelStore store,
                                                                                                          @Nullable
                                                                                                          String customLicensePrefix,
                                                                                                          @Nullable
                                                                                                          org.spdx.core.IModelCopyManager copyManager,
                                                                                                          @Nullable
                                                                                                          List<org.spdx.library.model.v3_0_1.core.DictionaryEntry> customIdToUri)
                                                                                                   throws org.spdx.library.model.v2.license.InvalidLicenseStringException,
                                                                                                          org.spdx.core.DefaultStoreNotInitialized
        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.
        customLicensePrefix - Prefix to use for any custom licenses or addition IDs found in the string. If the resultant object URI does not 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
        customIdToUri - Mapping of the id prefixes used in the license expression to the namespace preceding the external ID
        Returns:
        an SPDXLicenseInfo created from the string
        Throws:
        org.spdx.library.model.v2.license.InvalidLicenseStringException - if the license string is not valid
        org.spdx.core.DefaultStoreNotInitialized - if the default model store is not initialized
      • parseSPDXLicenseString

        public static org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo parseSPDXLicenseString​(String licenseString)
                                                                                                   throws org.spdx.library.model.v2.license.InvalidLicenseStringException,
                                                                                                          org.spdx.core.DefaultStoreNotInitialized
        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:
        org.spdx.library.model.v2.license.InvalidLicenseStringException - if the license string is not valid
        org.spdx.core.DefaultStoreNotInitialized - if the default model store is not initialized
      • parseSPDXLicenseStringCompatV2

        public static org.spdx.library.model.v2.license.AnyLicenseInfo parseSPDXLicenseStringCompatV2​(String licenseString)
                                                                                               throws org.spdx.library.model.v2.license.InvalidLicenseStringException,
                                                                                                      org.spdx.core.DefaultStoreNotInitialized
        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:
        org.spdx.library.model.v2.license.InvalidLicenseStringException
        org.spdx.core.DefaultStoreNotInitialized
      • 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 org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException getListedExceptionById​(String id)
                                                                                                             throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        id - ID for the listed exception
        Returns:
        the standard SPDX license exception or null if the ID is not in the SPDX license list
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException
      • getListedExceptionV2ById

        public static org.spdx.library.model.v2.license.ListedLicenseException getListedExceptionV2ById​(String id)
                                                                                                 throws org.spdx.core.InvalidSPDXAnalysisException
        Parameters:
        id - ID for the listed exception
        Returns:
        the standard SPDX license exception in SPDX Spec V2.X format or null if the ID is not in the SPDX license list
        Throws:
        org.spdx.core.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
      • getListedLicenseCreationInfo

        public static org.spdx.library.model.v3_0_1.core.CreationInfo getListedLicenseCreationInfo()
                                                                                            throws org.spdx.core.InvalidSPDXAnalysisException
        Returns:
        the CreationInfo used for all SPDX listed licenses and listed exceptions
        Throws:
        org.spdx.core.InvalidSPDXAnalysisException - on error inflating the creation info