Interface IModelStore

  • All Superinterfaces:
    AutoCloseable
    All Known Subinterfaces:
    ISerializableModelStore
    All Known Implementing Classes:
    NullModelStore

    public interface IModelStore
    extends AutoCloseable
    Service Provider Interface for storing and retrieving SPDX properties from the underlying store.

    The interface uses the URI 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 its 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
    • Method Detail

      • exists

        boolean exists​(String objectUri)
        Parameters:
        objectUri - unique URI within the SPDX model store for the objects
        Returns:
        true if the objectUri already exists for the document
      • setValue

        void setValue​(String objectUri,
                      PropertyDescriptor propertyDescriptor,
                      Object value)
               throws InvalidSPDXAnalysisException
        Sets a property value for a String or Boolean type of value creating the propertyDescriptor if it does not exist
        Parameters:
        objectUri - unique URI within the SPDX model store for the objects
        propertyDescriptor - descriptor for the property
        value - value to set
        Throws:
        InvalidSPDXAnalysisException - on model store errors
      • getNextId

        String getNextId​(IModelStore.IdType idType)
                  throws InvalidSPDXAnalysisException
        Generate a unique ID within the model store - Note: for a full URI, the id should be prepended with a URI prefix
        Parameters:
        idType - Type of ID
        Returns:
        next available unique ID for the specific idType - Note: for a full URI, the id should be prepended with a URI prefix
        Throws:
        InvalidSPDXAnalysisException - on model store errors
      • removeProperty

        void removeProperty​(String objectUri,
                            PropertyDescriptor propertyDescriptor)
                     throws InvalidSPDXAnalysisException
        Removes a property from the document for the given ID if the property exists. Does not raise any exception if the propertyDescriptor does not exist
        Parameters:
        objectUri - unique URI within the SPDX model store for the objects
        propertyDescriptor - descriptor for the property
        Throws:
        InvalidSPDXAnalysisException - on model store errors
      • leaveCriticalSection

        void leaveCriticalSection​(IModelStore.IModelStoreLock lock)
        Leave a critical section. Releases the lock form the matching enterCriticalSection
      • removeValueFromCollection

        boolean removeValueFromCollection​(String objectUri,
                                          PropertyDescriptor propertyDescriptor,
                                          Object value)
                                   throws InvalidSPDXAnalysisException
        Removes a value from a collection of values associated with a property
        Parameters:
        objectUri - unique URI within the SPDX model store for the objects
        propertyDescriptor - descriptor for the property
        value - Value to be removed
        Returns:
        true if the value was removed
        Throws:
        InvalidSPDXAnalysisException
      • collectionContains

        boolean collectionContains​(String objectUri,
                                   PropertyDescriptor propertyDescriptor,
                                   Object value)
                            throws InvalidSPDXAnalysisException
        Parameters:
        objectUri - unique URI within the SPDX model store for the objects
        propertyDescriptor - descriptor for the property
        value - value to check for contains
        Returns:
        true if the collection associated with a property contains the value
        Throws:
        InvalidSPDXAnalysisException
      • clearValueCollection

        void clearValueCollection​(String objectUri,
                                  PropertyDescriptor propertyDescriptor)
                           throws InvalidSPDXAnalysisException
        Sets the value collection for the property to an empty collection creating the propertyDescriptor if it does not exist
        Parameters:
        objectUri - unique URI within the SPDX model store for the objects
        propertyDescriptor - descriptor for the property
        Throws:
        InvalidSPDXAnalysisException - on model store errors
      • addValueToCollection

        boolean addValueToCollection​(String objectUri,
                                     PropertyDescriptor propertyDescriptor,
                                     Object value)
                              throws InvalidSPDXAnalysisException
        Adds a value to a property collection creating the propertyDescriptor if it does not exist
        Parameters:
        objectUri - unique URI within the SPDX model store for the objects
        propertyDescriptor - descriptor for the property
        value - value to add
        Returns:
        true if the collection was modified
        Throws:
        InvalidSPDXAnalysisException - on model store errors
      • isCollectionMembersAssignableTo

        boolean isCollectionMembersAssignableTo​(String objectUri,
                                                PropertyDescriptor propertyDescriptor,
                                                Class<?> clazz)
                                         throws InvalidSPDXAnalysisException
        Parameters:
        objectUri - unique URI within the SPDX model store for the objects
        propertyDescriptor - descriptor for the property
        clazz - Class to test compatibility with
        Returns:
        true if all members of a collection associated with the objectUri and propertyDescriptor can be assigned to the clazz
        Throws:
        InvalidSPDXAnalysisException - on model store errors
      • isPropertyValueAssignableTo

        boolean isPropertyValueAssignableTo​(String objectUri,
                                            PropertyDescriptor propertyDescriptor,
                                            Class<?> clazz,
                                            String specVersion)
                                     throws InvalidSPDXAnalysisException
        Parameters:
        objectUri - unique URI within the SPDX model store for the objects
        propertyDescriptor - descriptor for the property
        clazz - Class to test compatibility with
        specVersion - version of the SPDX to check against
        Returns:
        true if the value associated with the objectUri and propertyDescriptor can be assigned to the clazz
        Throws:
        InvalidSPDXAnalysisException - on model store errors
      • getIdType

        IModelStore.IdType getIdType​(String objectUri)
        Parameters:
        objectUri - URI for the object or the anon. ID
        Returns:
        The type of ID based on the string format
      • getCaseSensisitiveId

        @Deprecated
        default Optional<String> getCaseSensisitiveId​(String nameSpace,
                                                      String caseInsensisitiveId)
        Deprecated.
        As of release 1.0, replaced by getCaseSensitiveId(String, String)
        Alias for getCaseSensitiveId
        Parameters:
        nameSpace - the nameSpace used for the ID - the URI is formed by the nameSpace + "#" + caseInsensisitiveId
        caseInsensisitiveId - ID - case will be ignored
        Returns:
        the case-sensitive ID if it exists
      • getCaseSensitiveId

        default Optional<String> getCaseSensitiveId​(String nameSpace,
                                                    String caseInsensitiveId)
        In SPDX 2.2 license refs are allowed to be matched case-insensitive. This function will return the case-sensitive ID (e.g. if you have LicenseRef-ABC, calling this function with licenseref-abc will return LicenseRef-ABC
        Parameters:
        nameSpace - the nameSpace used for the ID - the URI is formed by the nameSpace + "#" + caseInsensitiveId
        caseInsensitiveId - ID - case will be ignored
        Returns:
        the case-sensitive ID if it exists
      • isAnon

        boolean isAnon​(String objectUri)
        Parameters:
        objectUri - ID or URI for an item
        Returns:
        true if the ID is anonymous