Class LicenseInfoFactory
java.lang.Object
org.spdx.library.LicenseInfoFactory
Factory for creating SPDXLicenseInfo objects from a Jena model
- Author:
- Gary O'Neall
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseExceptionstatic org.spdx.library.model.v2.license.ListedLicenseExceptionstatic org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicensegetListedLicenseById(String licenseId) static org.spdx.library.model.v2.license.SpdxListedLicensegetListedLicenseByIdCompatV2(String licenseId) static org.spdx.library.model.v3_0_1.core.CreationInfostatic booleanstatic booleanisSpdxListedLicenseId(String licenseID) listedExceptionIdCaseSensitive(String exceptionId) listedLicenseIdCaseSensitive(String licenseId) static org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfoparseSPDXLicenseString(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.AnyLicenseInfoparseSPDXLicenseString(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 using the default creation information 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.AnyLicenseInfoparseSPDXLicenseString(String licenseString, org.spdx.storage.IModelStore store, String customLicensePrefix, org.spdx.library.model.v3_0_1.core.CreationInfo creationInfo, 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.AnyLicenseInfoparseSPDXLicenseStringCompatV2(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.AnyLicenseInfoparseSPDXLicenseStringCompatV2(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"
-
Field Details
-
NOASSERTION_LICENSE_NAME
- See Also:
-
NONE_LICENSE_NAME
- See Also:
-
-
Constructor Details
-
LicenseInfoFactory
public LicenseInfoFactory()
-
-
Method Details
-
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.DefaultStoreNotInitializedException 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 syntaxstore- 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- allows for copying of any properties set which use other model stores or document URI's. If null, the default will be used.- Returns:
- an SPDXLicenseInfo created from the string. If the license expression is not parseable, a
InvalidLicenseExpressionis returned. - Throws:
org.spdx.core.DefaultStoreNotInitializedException- if the default model store is not initializedorg.spdx.library.model.v2.license.InvalidLicenseStringException
-
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.library.model.v3_0_1.core.CreationInfo creationInfo, @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.DefaultStoreNotInitializedException 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 syntaxstore- 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.creationInfo- Creation information to use for newly created elements. If null, the defaultcopyManager- allows for copying of any properties set which use other model stores or document URI's. If null, the default will be used.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. If the license expression is not parseable, a
InvalidLicenseExpressionis returned. - Throws:
org.spdx.core.DefaultStoreNotInitializedException- if the default model store is not initializedorg.spdx.library.model.v2.license.InvalidLicenseStringException
-
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.DefaultStoreNotInitializedException Parses a license string and converts it into a SPDXLicenseInfo object using the default creation information 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 syntaxstore- 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- allows for copying of any properties set which use other model stores or document URI's. If null, the default will be used.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. If the license expression is not parseable, a
InvalidLicenseExpressionis returned. - Throws:
org.spdx.core.DefaultStoreNotInitializedException- if the default model store is not initializedorg.spdx.library.model.v2.license.InvalidLicenseStringException
-
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.DefaultStoreNotInitializedException 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 validorg.spdx.core.DefaultStoreNotInitializedException- 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.DefaultStoreNotInitializedException 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- On invalid license expressionorg.spdx.core.DefaultStoreNotInitializedException- On the model store not being initialized - see DefaultModelStore in SPDX core package
-
isSpdxListedLicenseId
- Parameters:
licenseID- case insensitive- Returns:
- true if the licenseID belongs to an SPDX listed license
-
getSpdxListedLicenseIds
-
getLicenseListVersion
- Returns:
- Version of the license list being used by the SPDXLicenseInfoFactory
-
isSpdxListedExceptionId
- 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- On SPDX parsing errors
-
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- On SPDX parsing errors
-
listedLicenseIdCaseSensitive
-
listedExceptionIdCaseSensitive
-
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
-