Package org.spdx.library.model.license
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 Summary
Fields Modifier and Type Field Description static StringNOASSERTION_LICENSE_NAMEstatic StringNONE_LICENSE_NAME -
Constructor Summary
Constructors Constructor Description LicenseInfoFactory() -
Method Summary
Modifier and Type Method Description static StringgetLicenseListVersion()static ListedLicenseExceptiongetListedExceptionById(String id)static SpdxListedLicensegetListedLicenseById(String licenseId)static List<String>getSpdxListedLicenseIds()static booleanisSpdxListedExceptionId(String id)static booleanisSpdxListedLicenseId(String licenseID)static Optional<String>listedExceptionIdCaseSensitive(String exceptionId)static Optional<String>listedLicenseIdCaseSensitive(String licenseId)static 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 AnyLicenseInfoparseSPDXLicenseString(String licenseString, IModelStore store, String documentUri, ModelCopyManager 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:
- Constant Field Values
-
NONE_LICENSE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Details
-
LicenseInfoFactory
public LicenseInfoFactory()
-
-
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 InvalidLicenseStringExceptionParses 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- 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 InvalidLicenseStringExceptionParses 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
- Parameters:
licenseID- case insensitive- Returns:
- true if the licenseID belongs to an SPDX listed license
-
getSpdxListedLicenseIds
- Returns:
- Array of all SPDX listed license IDs
-
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 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
- Parameters:
licenseId- case insensitive license ID- Returns:
- the case sensitive license ID
-
listedExceptionIdCaseSensitive
- Parameters:
exceptionId- case insensitive exception ID- Returns:
- case sensitive ID
-