Package org.spdx.storage.listedlicense
Class SpdxListedLicenseModelStore
java.lang.Object
org.spdx.storage.listedlicense.SpdxListedLicenseModelStore
- All Implemented Interfaces:
AutoCloseable,IModelStore,IListedLicenseStore
- Direct Known Subclasses:
SpdxListedLicenseLocalStore,SpdxListedLicenseWebStore
public abstract class SpdxListedLicenseModelStore extends Object implements IListedLicenseStore
Read-only model store for the SPDX listed licenses
License and exception ID's can be case insensitive
License information is stored in a LicenseJson file with the ID being Listed License ID
License Exception information is stored in an ExceptionJson file with the ID being the Listed Exception ID
CrossRef information is stored within the LicenseJson file. Id's are anonymous and generated.
- Author:
- Gary O'Neall
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spdx.storage.IModelStore
IModelStore.IdType, IModelStore.IModelStoreLock, IModelStore.ModelUpdate -
Constructor Summary
Constructors Constructor Description SpdxListedLicenseModelStore() -
Method Summary
Modifier and Type Method Description booleanaddValueToCollection(String documentUri, String id, String propertyName, Object value)Adds a value to a property collection creating the propertyName if it does not existvoidclearValueCollection(String documentUri, String id, String propertyName)Sets the value collection for the property to an empty collection creating the propertyName if it does not existbooleancollectionContains(String documentUri, String id, String propertyName, Object value)intcollectionSize(String documentUri, String id, String propertyName)voidcreate(String documentUri, String id, String type)Create a new object with IDvoiddelete(String documentUri, String id)Deletes an item from the documentIModelStore.IModelStoreLockenterCriticalSection(String documentUri, boolean readLockRequested)Enter a critical section.booleanexists(String documentUri, String id)Stream<TypedValue>getAllItems(String documentUri, String typeFilter)Optional<String>getCaseSensisitiveId(String documentUri, String caseInsensisitiveId)In SPDX 2.2 license refs are allowed to be matched case insensitive.List<String>getDocumentUris()IModelStore.IdTypegetIdType(String id)StringgetLicenseListVersion()StringgetNextId(IModelStore.IdType idType, String documentUri)Generate a unique ID for use within the documentList<String>getPropertyValueNames(String documentUri, String id)List<String>getSpdxListedExceptionIds()List<String>getSpdxListedLicenseIds()Optional<TypedValue>getTypedValue(String documentUri, String id)Optional<Object>getValue(String documentUri, String id, String propertyName)booleanisCollectionMembersAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz)booleanisCollectionProperty(String documentUri, String id, String propertyName)booleanisPropertyValueAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz)booleanisSpdxListedExceptionId(String listedLicenseDocumentUri, String exceptionId)booleanisSpdxListedLicenseId(String listedLicenseDocumentUri, String licenseId)voidleaveCriticalSection(IModelStore.IModelStoreLock lock)Leave a critical section.Optional<String>listedExceptionIdCaseSensitive(String exceptionId)Optional<String>listedLicenseIdCaseSensitive(String licenseId)Iterator<Object>listValues(String documentUri, String id, String propertyName)voidremoveProperty(String documentUri, String id, String propertyName)Removes a property from the document for the given ID if the property exists.booleanremoveValueFromCollection(String documentUri, String id, String propertyName, Object value)Removes a value from a collection of values associated with a propertyvoidsetValue(String documentUri, String id, String propertyName, Object value)Sets a property value for a String or Boolean type of value creating the propertyName if it does not exist
-
Constructor Details
-
Method Details
-
exists
- Specified by:
existsin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX document- Returns:
- true if the id already exists for the document
-
create
Description copied from interface:IModelStoreCreate a new object with ID- Specified by:
createin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documenttype- SPDX model type as defined in the CLASS constants in SpdxConstants- Throws:
InvalidSPDXAnalysisException
-
getPropertyValueNames
public List<String> getPropertyValueNames(String documentUri, String id) throws InvalidSPDXAnalysisException- Specified by:
getPropertyValueNamesin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX document- Returns:
- Property names for all properties having a value for a given id within a document
- Throws:
InvalidSPDXAnalysisException
-
setValue
public void setValue(String documentUri, String id, String propertyName, Object value) throws InvalidSPDXAnalysisExceptionDescription copied from interface:IModelStoreSets a property value for a String or Boolean type of value creating the propertyName if it does not exist- Specified by:
setValuein interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the propertyvalue- value to set- Throws:
InvalidSPDXAnalysisException
-
clearValueCollection
public void clearValueCollection(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisExceptionDescription copied from interface:IModelStoreSets the value collection for the property to an empty collection creating the propertyName if it does not exist- Specified by:
clearValueCollectionin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the property- Throws:
InvalidSPDXAnalysisException
-
addValueToCollection
public boolean addValueToCollection(String documentUri, String id, String propertyName, Object value) throws InvalidSPDXAnalysisExceptionDescription copied from interface:IModelStoreAdds a value to a property collection creating the propertyName if it does not exist- Specified by:
addValueToCollectionin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the propertyvalue- value to add- Returns:
- true if the collection was modified
- Throws:
InvalidSPDXAnalysisException
-
removeValueFromCollection
public boolean removeValueFromCollection(String documentUri, String id, String propertyName, Object value) throws InvalidSPDXAnalysisExceptionDescription copied from interface:IModelStoreRemoves a value from a collection of values associated with a property- Specified by:
removeValueFromCollectionin interfaceIModelStore- Parameters:
documentUri- Unique document URIid- ID of the item to associate the property withpropertyName- name of the propertyvalue- Value to be removed- Returns:
- Throws:
InvalidSPDXAnalysisException
-
listValues
public Iterator<Object> listValues(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException- Specified by:
listValuesin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the property- Returns:
- Iterator over the list of values associated with the id, propertyName and document
- Throws:
InvalidSPDXAnalysisException
-
getValue
public Optional<Object> getValue(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException- Specified by:
getValuein interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the property- Returns:
- the single value associated with the id, propertyName and document
- Throws:
InvalidSPDXAnalysisException
-
getNextId
public String getNextId(IModelStore.IdType idType, String documentUri) throws InvalidSPDXAnalysisExceptionDescription copied from interface:IModelStoreGenerate a unique ID for use within the document- Specified by:
getNextIdin interfaceIModelStore- Parameters:
idType- Type of IDdocumentUri- the SPDX Document URI- Returns:
- next available unique ID for the specific idType
- Throws:
InvalidSPDXAnalysisException
-
getSpdxListedLicenseIds
- Specified by:
getSpdxListedLicenseIdsin interfaceIListedLicenseStore- Returns:
- List of all SPDX listed license IDs
-
getLicenseListVersion
- Specified by:
getLicenseListVersionin interfaceIListedLicenseStore- Returns:
- The version of the loaded license list in the form M.N, where M is the major release and N is the minor release.
-
getSpdxListedExceptionIds
- Specified by:
getSpdxListedExceptionIdsin interfaceIListedLicenseStore- Returns:
- list of SPDX exception IDs
-
isSpdxListedLicenseId
- Specified by:
isSpdxListedLicenseIdin interfaceIListedLicenseStore- Parameters:
listedLicenseDocumentUri-licenseId-- Returns:
- true if the licenseId belongs to an SPDX listed license
-
isSpdxListedExceptionId
- Specified by:
isSpdxListedExceptionIdin interfaceIListedLicenseStore- Parameters:
listedLicenseDocumentUri-exceptionId-- Returns:
- true if the exceptionId belongs to an SPDX listed exception
-
getTypedValue
public Optional<TypedValue> getTypedValue(String documentUri, String id) throws InvalidSPDXAnalysisException- Specified by:
getTypedValuein interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX document- Returns:
- type TypedValue containing the type of the ModelObject related to the ID
- Throws:
InvalidSPDXAnalysisException
-
removeProperty
public void removeProperty(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisExceptionDescription copied from interface:IModelStoreRemoves a property from the document for the given ID if the property exists. Does not raise any exception if the propertyName does not exist- Specified by:
removePropertyin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the property- Throws:
InvalidSPDXAnalysisException
-
getDocumentUris
- Specified by:
getDocumentUrisin interfaceIModelStore- Returns:
- a list of all Document URI's stored in the model store
-
getAllItems
public Stream<TypedValue> getAllItems(String documentUri, @Nullable String typeFilter) throws InvalidSPDXAnalysisException- Specified by:
getAllItemsin interfaceIModelStore- Parameters:
documentUri- SPDX Document URI for a document associated with this modeltypeFilter- Optional parameter to specify the type of objects to be retrieved- Returns:
- Stream of all items store within the document
- Throws:
InvalidSPDXAnalysisException
-
collectionSize
public int collectionSize(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException- Specified by:
collectionSizein interfaceIModelStore- Parameters:
documentUri- Unique document URIid- ID of the item to associate the property withpropertyName- name of the property- Returns:
- size of a collection associated with a property. 0 if the property does not exist.
- Throws:
InvalidSPDXAnalysisException
-
collectionContains
public boolean collectionContains(String documentUri, String id, String propertyName, Object value) throws InvalidSPDXAnalysisException- Specified by:
collectionContainsin interfaceIModelStore- Parameters:
documentUri- Unique document URIid- ID of the item to associate the property withpropertyName- name of the property- Returns:
- true if the collection associated with a property contains the value
- Throws:
InvalidSPDXAnalysisException
-
isCollectionMembersAssignableTo
public boolean isCollectionMembersAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) throws InvalidSPDXAnalysisException- Specified by:
isCollectionMembersAssignableToin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the propertyclazz- Class to test compatibility with- Returns:
- true if all members of a collection associated with the id and propertyName can be assigned to the clazz
- Throws:
InvalidSPDXAnalysisException
-
isPropertyValueAssignableTo
public boolean isPropertyValueAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) throws InvalidSPDXAnalysisException- Specified by:
isPropertyValueAssignableToin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the propertyclazz- Class to test compatibility with- Returns:
- true if the value associated with the id and propertyName can be assigned to the clazz
- Throws:
InvalidSPDXAnalysisException
-
isCollectionProperty
public boolean isCollectionProperty(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException- Specified by:
isCollectionPropertyin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the property- Returns:
- true if the propertyName represents multiple values
- Throws:
InvalidSPDXAnalysisException
-
getIdType
- Specified by:
getIdTypein interfaceIModelStore- Returns:
- The type of ID based on the string format
-
enterCriticalSection
public IModelStore.IModelStoreLock enterCriticalSection(String documentUri, boolean readLockRequested)Description copied from interface:IModelStoreEnter a critical section. leaveCriticialSection must be called.- Specified by:
enterCriticalSectionin interfaceIModelStorereadLockRequested- true implies a read lock, false implies write lock.
-
leaveCriticalSection
Description copied from interface:IModelStoreLeave a critical section. Releases the lock form the matching enterCriticalSection- Specified by:
leaveCriticalSectionin interfaceIModelStore
-
listedLicenseIdCaseSensitive
- Specified by:
listedLicenseIdCaseSensitivein interfaceIListedLicenseStore- Parameters:
licenseId- case insensitive license ID- Returns:
- the case sensitive license ID
-
listedExceptionIdCaseSensitive
- Specified by:
listedExceptionIdCaseSensitivein interfaceIListedLicenseStore- Parameters:
exceptionId- case insensitive exception ID- Returns:
- case sensitive ID
-
getCaseSensisitiveId
Description copied from interface:IModelStoreIn SPDX 2.2 license refs are allowed to be matched case insensitive. This function will return the case sensitivie ID (e.g. if you have LicenseRef-ABC, calling this function with licenseref-abc will return LicenseRef-ABC- Specified by:
getCaseSensisitiveIdin interfaceIModelStore- Parameters:
documentUri- the SPDX Document URI- Returns:
- the case sensitive ID if it exists
-
delete
Description copied from interface:IModelStoreDeletes an item from the document- Specified by:
deletein interfaceIModelStore- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX document- Throws:
InvalidSPDXAnalysisException
-