Package org.spdx.library
Class ListedLicenses
- java.lang.Object
-
- org.spdx.library.ListedLicenses
-
public class ListedLicenses extends Object
Singleton class which holds the listed licenses- Author:
- Gary O'Neall
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getLicenseListVersion()
Retrieve the version of the loaded SPDX license listorg.spdx.storage.IModelStore
getLicenseModelStore()
Retrieve the model store for listed licenses using the SPDX version 3 modelorg.spdx.storage.IModelStore
getLicenseModelStoreCompatV2()
Retrieve the model store for listed licenses using the SPDX version 2 modelorg.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException
getListedExceptionById(String exceptionId)
Retrieve an SPDX listed license exception by its IDorg.spdx.library.model.v2.license.ListedLicenseException
getListedExceptionByIdCompatV2(String exceptionId)
Retrieve an SPDX listed license exception by its ID for SPDX specification version 2 compatibilityorg.spdx.library.model.v3_0_1.expandedlicensing.ListedLicense
getListedLicenseById(String licenseId)
Retrieve an SPDX listed license by its IDorg.spdx.library.model.v2.license.SpdxListedLicense
getListedLicenseByIdCompatV2(String licenseId)
Retrieve an SPDX listed license by its ID for SPDX specification version 2 compatibilityorg.spdx.library.model.v3_0_1.core.CreationInfo
getListedLicenseCreationInfo()
Retrieve the creation information for all SPDX listed licenses and exceptionsstatic ListedLicenses
getListedLicenses()
Retrieve the singleton instance of theListedLicenses
classList<String>
getSpdxListedExceptionIds()
Retrieve a list of all SPDX listed exception IDsMap<String,org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException>
getSpdxListedLicenseExceptions()
Retrieve a map of SPDX Listed License Exception IDs to their SPDX listed license exceptionsprotected Map<String,org.spdx.library.model.v2.license.ListedLicenseException>
getSpdxListedLicenseExceptionsCompatV2()
Retrieve a map of SPDX Listed License Exception IDs to their SPDX listed license exceptions for SPDX specification version 2 compatibilityList<String>
getSpdxListedLicenseIds()
Retrieve a list of all SPDX listed license IDsMap<String,org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicense>
getSpdxListedLicenses()
Retrieve a map of SPDX Listed License IDs to their SPDX listed licensesprotected Map<String,org.spdx.library.model.v2.license.SpdxListedLicense>
getSpdxListedLicensesCompatV2()
Retrieve a map of SPDX Listed License IDs to their SPDX listed licenses for SPDX specification version 2 compatibilityboolean
isSpdxListedExceptionId(String exceptionId)
Check whether the given exception ID belongs to an SPDX listed exceptionboolean
isSpdxListedLicenseId(String licenseId)
Check whether the given license ID belongs to an SPDX listed licenseOptional<String>
listedExceptionIdCaseSensitive(String exceptionId)
Retrieve the case-sensitive SPDX exception ID for a given case-insensitive exception IDOptional<String>
listedLicenseIdCaseSensitive(String licenseId)
Retrieve the case-sensitive SPDX license ID for a given case-insensitive license IDstatic ListedLicenses
resetListedLicenses()
Reset all cached license information and reload the license IDs
-
-
-
Method Detail
-
getListedLicenses
public static ListedLicenses getListedLicenses()
Retrieve the singleton instance of theListedLicenses
classThis method ensures that only one instance of the
ListedLicenses
class is created and shared throughout the application. If the instance does not already exist, it is initialized.- Returns:
- The singleton instance of the
ListedLicenses
class.
-
resetListedLicenses
public static ListedLicenses resetListedLicenses()
Reset all cached license information and reload the license IDsNOTE: This method should be used with caution as it can negatively impact performance due to the reloading process.
- Returns:
- A new instance of the
ListedLicenses
class.
-
isSpdxListedLicenseId
public boolean isSpdxListedLicenseId(String licenseId)
Check whether the given license ID belongs to an SPDX listed license- Parameters:
licenseId
- The case-insensitive SPDX license ID.- Returns:
true
if the license ID belongs to an SPDX listed license,false
otherwise.
-
isSpdxListedExceptionId
public boolean isSpdxListedExceptionId(String exceptionId)
Check whether the given exception ID belongs to an SPDX listed exception- Parameters:
exceptionId
- The case-insensitive SPDX exception ID to check.- Returns:
true
if the exception ID belongs to an SPDX listed exception,false
otherwise.
-
getListedLicenseByIdCompatV2
public org.spdx.library.model.v2.license.SpdxListedLicense getListedLicenseByIdCompatV2(String licenseId) throws org.spdx.core.InvalidSPDXAnalysisException
Retrieve an SPDX listed license by its ID for SPDX specification version 2 compatibility- Parameters:
licenseId
- The SPDX Listed License ID.- Returns:
- The SPDX specification version 2 listed license, or
null
if the ID is not in the SPDX License List. - Throws:
org.spdx.core.InvalidSPDXAnalysisException
- If an error occurs while retrieving the license.
-
getListedExceptionByIdCompatV2
public org.spdx.library.model.v2.license.ListedLicenseException getListedExceptionByIdCompatV2(String exceptionId) throws org.spdx.core.InvalidSPDXAnalysisException
Retrieve an SPDX listed license exception by its ID for SPDX specification version 2 compatibility- Parameters:
exceptionId
- The SPDX Listed License Exception ID.- Returns:
- The SPDX specification version 2 listed license exception, or
null
if the ID is not in the SPDX License List. - Throws:
org.spdx.core.InvalidSPDXAnalysisException
- If an error occurs while retrieving the exception.
-
getListedLicenseById
public org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicense getListedLicenseById(String licenseId) throws org.spdx.core.InvalidSPDXAnalysisException
Retrieve an SPDX listed license by its ID- Parameters:
licenseId
- The SPDX Listed License ID.- Returns:
- The SPDX listed license, or
null
if not in the SPDX License List. - Throws:
org.spdx.core.InvalidSPDXAnalysisException
- If an error occurs while retrieving the license.
-
getListedExceptionById
public org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException getListedExceptionById(String exceptionId) throws org.spdx.core.InvalidSPDXAnalysisException
Retrieve an SPDX listed license exception by its ID- Parameters:
exceptionId
- The SPDX Listed License Exception ID.- Returns:
- The SPDX listed license exception, or
null
if not in the SPDX License List. - Throws:
org.spdx.core.InvalidSPDXAnalysisException
- If an error occurs while retrieving the exception.
-
getSpdxListedLicenseIds
public List<String> getSpdxListedLicenseIds()
Retrieve a list of all SPDX listed license IDs- Returns:
- A list of all SPDX Listed License IDs.
-
getSpdxListedLicenses
public Map<String,org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicense> getSpdxListedLicenses() throws org.spdx.core.InvalidSPDXAnalysisException
Retrieve a map of SPDX Listed License IDs to their SPDX listed licenses- Returns:
- A map where the keys are SPDX Listed License IDs and the values are
ListedLicense
objects. - Throws:
org.spdx.core.InvalidSPDXAnalysisException
- If an error occurs while fetching the licenses.
-
getSpdxListedLicenseExceptions
public Map<String,org.spdx.library.model.v3_0_1.expandedlicensing.ListedLicenseException> getSpdxListedLicenseExceptions() throws org.spdx.core.InvalidSPDXAnalysisException
Retrieve a map of SPDX Listed License Exception IDs to their SPDX listed license exceptions- Returns:
- A map where the keys are SPDX Listed License Exception IDs
and the values are
ListedLicenseException
objects. - Throws:
org.spdx.core.InvalidSPDXAnalysisException
- If an error occurs while fetching the license exceptions.
-
getSpdxListedLicensesCompatV2
protected Map<String,org.spdx.library.model.v2.license.SpdxListedLicense> getSpdxListedLicensesCompatV2() throws org.spdx.core.InvalidSPDXAnalysisException
Retrieve a map of SPDX Listed License IDs to their SPDX listed licenses for SPDX specification version 2 compatibility- Returns:
- A map where the keys are SPDX Listed License IDs and the values are
SpdxListedLicense
(SPDX spec version 2) objects. - Throws:
org.spdx.core.InvalidSPDXAnalysisException
- If an error occurs while fetching the licenses.
-
getSpdxListedLicenseExceptionsCompatV2
protected Map<String,org.spdx.library.model.v2.license.ListedLicenseException> getSpdxListedLicenseExceptionsCompatV2() throws org.spdx.core.InvalidSPDXAnalysisException
Retrieve a map of SPDX Listed License Exception IDs to their SPDX listed license exceptions for SPDX specification version 2 compatibility- Returns:
- A map where the keys are SPDX Listed License Exception IDs
and the values are
ListedLicenseException
(SPDX spec version 2) objects. - Throws:
org.spdx.core.InvalidSPDXAnalysisException
- If an error occurs while fetching the license exceptions.
-
getLicenseListVersion
public String getLicenseListVersion()
Retrieve the version of the loaded SPDX license listThe version is returned in the format "M.N", where M is the major release and N is the minor release. If no license list is loaded, this method returns the default license list version.
- Returns:
- The version of the loaded SPDX license list, or the default version if no license list is loaded.
-
getSpdxListedExceptionIds
public List<String> getSpdxListedExceptionIds()
Retrieve a list of all SPDX listed exception IDs- Returns:
- A list of SPDX listed exception IDs.
-
listedLicenseIdCaseSensitive
public Optional<String> listedLicenseIdCaseSensitive(String licenseId)
Retrieve the case-sensitive SPDX license ID for a given case-insensitive license ID
-
listedExceptionIdCaseSensitive
public Optional<String> listedExceptionIdCaseSensitive(String exceptionId)
Retrieve the case-sensitive SPDX exception ID for a given case-insensitive exception ID
-
getLicenseModelStore
public org.spdx.storage.IModelStore getLicenseModelStore()
Retrieve the model store for listed licenses using the SPDX version 3 model- Returns:
- The
IModelStore
for SPDX version 3 listed licenses and exceptions.
-
getLicenseModelStoreCompatV2
public org.spdx.storage.IModelStore getLicenseModelStoreCompatV2()
Retrieve the model store for listed licenses using the SPDX version 2 model- Returns:
- The
IModelStore
for SPDX version 2 listed licenses and exceptions.
-
getListedLicenseCreationInfo
public org.spdx.library.model.v3_0_1.core.CreationInfo getListedLicenseCreationInfo() throws org.spdx.core.InvalidSPDXAnalysisException
Retrieve the creation information for all SPDX listed licenses and exceptions- Returns:
- The
CreationInfo
used for all SPDX listed licenses and exceptions. - Throws:
org.spdx.core.InvalidSPDXAnalysisException
- If an error occurs while inflating the creation information.
-
-