Package org.spdx.storage
Interface IModelStore
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
IListedLicenseStore,ISerializableModelStore
- All Known Implementing Classes:
ExtendedSpdxStore,InMemSpdxStore,SpdxListedLicenseLocalStore,SpdxListedLicenseModelStore,SpdxListedLicenseWebStore
Service Provider Interface for storing and retrieving SPDX properties for SPDX documents.
The interface uses the SPDX document URI and an ID to identify specific objects stored.
Each object can have property values and property value lists associated with them.
A property value is an object of a primitive type (e.g. String or Boolean) or is another
object which includes it's own ID and must also have a type described in the SPDX model.
A property list is just a list of values.
- Author:
- Gary O'Neall
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumDifferent types of ID'sstatic interfacestatic interface -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddValueToCollection(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 a new object with IDvoidDeletes an item from the documententerCriticalSection(String documentUri, boolean readLockRequested) Enter a critical section.booleangetAllItems(String documentUri, String typeFilter) getCaseSensisitiveId(String documentUri, String caseInsensisitiveId) In SPDX 2.2 license refs are allowed to be matched case insensitive.getNextId(IModelStore.IdType idType, String documentUri) Generate a unique ID for use within the documentgetPropertyValueNames(String documentUri, String id) getTypedValue(String documentUri, String id) 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) voidLeave a critical section.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 propertyvoidSets a property value for a String or Boolean type of value creating the propertyName if it does not existMethods inherited from interface java.lang.AutoCloseable
close
-
Method Details
-
exists
- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX document- Returns:
- true if the id already exists for the document
-
create
Create a new object with ID- 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
List<String> getPropertyValueNames(String documentUri, String id) throws InvalidSPDXAnalysisException - 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
void setValue(String documentUri, String id, String propertyName, Object value) throws InvalidSPDXAnalysisException Sets a property value for a String or Boolean type of value creating the propertyName if it does not exist- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the propertyvalue- value to set- Throws:
InvalidSPDXAnalysisException
-
getValue
Optional<Object> getValue(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException - 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
Generate a unique ID for use within the document- Parameters:
idType- Type of IDdocumentUri- the SPDX Document URI- Returns:
- next available unique ID for the specific idType
- Throws:
InvalidSPDXAnalysisException
-
removeProperty
void removeProperty(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException Removes a property from the document for the given ID if the property exists. Does not raise any exception if the propertyName does not exist- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the property- Throws:
InvalidSPDXAnalysisException
-
getDocumentUris
- Returns:
- a list of all Document URI's stored in the model store
-
getAllItems
Stream<TypedValue> getAllItems(String documentUri, @Nullable String typeFilter) throws InvalidSPDXAnalysisException - 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
-
enterCriticalSection
IModelStore.IModelStoreLock enterCriticalSection(String documentUri, boolean readLockRequested) throws InvalidSPDXAnalysisException Enter a critical section. leaveCriticialSection must be called.- Parameters:
readLockRequested- true implies a read lock, false implies write lock.- Throws:
InvalidSPDXAnalysisException
-
leaveCriticalSection
Leave a critical section. Releases the lock form the matching enterCriticalSection -
removeValueFromCollection
boolean removeValueFromCollection(String documentUri, String id, String propertyName, Object value) throws InvalidSPDXAnalysisException Removes a value from a collection of values associated with a property- 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
-
collectionSize
int collectionSize(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException - 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
boolean collectionContains(String documentUri, String id, String propertyName, Object value) throws InvalidSPDXAnalysisException - Parameters:
documentUri- Unique document URIid- ID of the item to associate the property withpropertyName- name of the propertyvalue-- Returns:
- true if the collection associated with a property contains the value
- Throws:
InvalidSPDXAnalysisException
-
clearValueCollection
void clearValueCollection(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException Sets the value collection for the property to an empty collection creating the propertyName if it does not exist- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX documentpropertyName- Name of the property- Throws:
InvalidSPDXAnalysisException
-
addValueToCollection
boolean addValueToCollection(String documentUri, String id, String propertyName, Object value) throws InvalidSPDXAnalysisException Adds a value to a property collection creating the propertyName if it does not exist- 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
-
listValues
Iterator<Object> listValues(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException - 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
-
isCollectionMembersAssignableTo
boolean isCollectionMembersAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) throws InvalidSPDXAnalysisException - 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
boolean isPropertyValueAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) throws InvalidSPDXAnalysisException - 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
boolean isCollectionProperty(String documentUri, String id, String propertyName) throws InvalidSPDXAnalysisException - 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
- Parameters:
id-- Returns:
- The type of ID based on the string format
-
getCaseSensisitiveId
In 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- Parameters:
documentUri- the SPDX Document URIcaseInsensisitiveId-- Returns:
- the case sensitive ID if it exists
-
getTypedValue
Optional<TypedValue> getTypedValue(String documentUri, String id) throws InvalidSPDXAnalysisException - 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
-
delete
Deletes an item from the document- Parameters:
documentUri- the SPDX Document URIid- unique ID within the SPDX document- Throws:
InvalidSPDXAnalysisException
-