Class StoredTypedItem

java.lang.Object
org.spdx.core.TypedValue
org.spdx.storage.simple.StoredTypedItem

public class StoredTypedItem extends org.spdx.core.TypedValue
Individual item to be stored in memory
Author:
Gary O'Neall
  • Constructor Summary

    Constructors
    Constructor
    Description
    StoredTypedItem(String objectUri, String type, String specVersion)
    Construct a new StoredTypedItem with the specified object URI, type, and specification version
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addValueToList(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)
    Add a value to a property list for a String or Boolean type of value creating the propertyDescriptor if it does not exist
    void
    clearPropertyValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor)
    Set the value list for the property to an empty list creating the propertyDescriptor if it does not exist
    boolean
    collectionContains(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)
    Check whether the specified value exists in the collection associated with the given property descriptor
    int
    collectionSize(org.spdx.storage.PropertyDescriptor propertyDescriptor)
    Retrieve the size of the collection associated with the specified property descriptor
    void
    copyValuesFrom(org.spdx.storage.IModelStore store)
    Copy all values for this item from another model store
    int
    Decrement the reference count for this stored type item
    List<org.spdx.storage.PropertyDescriptor>
    Retrieve the property descriptors for all properties that have a value
    int
    Retrieve the current reference count for this stored item
    getValue(org.spdx.storage.PropertyDescriptor propertyDescriptor)
    Retrieve the value associated with the specified property descriptor
    getValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor)
    Retrieve an iterator over the list of values associated with the specified property descriptor
    int
    Increment the reference count for this stored type item - the number of times this item is referenced
    boolean
    isCollectionMembersAssignableTo(org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz)
    Check whether all members of the collection associated with the specified property descriptor can be assigned to the specified class
    boolean
    isCollectionProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor)
    Check whether the specified property descriptor is associated with a collection
    boolean
    isPropertyValueAssignableTo(org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz, String specVersion)
    Check whether the value associated with the specified property descriptor can be assigned to the specified class
    void
    removeProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor)
    Remove a property from the document for the given ID if the property exists
    boolean
    removeTypedValueFromList(org.spdx.storage.PropertyDescriptor propertyDescriptor, org.spdx.core.TypedValue value)
    Remove a property from a property list if it exists
    boolean
    removeValueFromList(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)
    Remove a property from a property list if it exists
    void
    setValue(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)
    Set the value for the specified property descriptor
    boolean
    usesId(String elementId)
    Check whether the specified element ID is used as a value in any collection or property

    Methods inherited from class org.spdx.core.TypedValue

    equals, getObjectUri, getSpecVersion, getType, hashCode, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • StoredTypedItem

      public StoredTypedItem(String objectUri, String type, String specVersion) throws org.spdx.core.InvalidSPDXAnalysisException
      Construct a new StoredTypedItem with the specified object URI, type, and specification version

      This constructor initializes a stored typed item, which represents an individual item to be stored in memory with its associated properties and metadata.

      Parameters:
      objectUri - The unique URI identifying this stored item.
      type - The type of the stored item.
      specVersion - The version of the SPDX specification associated with this item.
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - If the provided parameters are invalid or violate SPDX constraints.
  • Method Details

    • getPropertyValueDescriptors

      public List<org.spdx.storage.PropertyDescriptor> getPropertyValueDescriptors()
      Retrieve the property descriptors for all properties that have a value

      This method iterates through the stored properties and collects the descriptors for all properties that currently have an associated value.

      Returns:
      An unmodifiable List of PropertyDescriptor objects representing the properties that have values.
    • incReferenceCount

      public int incReferenceCount()
      Increment the reference count for this stored type item - the number of times this item is referenced
      Returns:
      The new number of times this item is referenced.
    • decReferenceCount

      public int decReferenceCount() throws org.spdx.core.SpdxInvalidTypeException
      Decrement the reference count for this stored type item
      Returns:
      The new number of times this item is referenced.
      Throws:
      org.spdx.core.SpdxInvalidTypeException - on invalid type
    • getReferenceCount

      public int getReferenceCount()
      Retrieve the current reference count for this stored item
      Returns:
      The current number of times this item is referenced.
    • setValue

      public void setValue(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.SpdxInvalidTypeException
      Set the value for the specified property descriptor
      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      value - The value to be set. Must not be null.
      Throws:
      org.spdx.core.SpdxInvalidTypeException - on invalid type
    • clearPropertyValueList

      public void clearPropertyValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.SpdxInvalidTypeException
      Set the value list for the property to an empty list creating the propertyDescriptor if it does not exist
      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      Throws:
      org.spdx.core.SpdxInvalidTypeException - on invalid type
    • addValueToList

      public boolean addValueToList(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.SpdxInvalidTypeException
      Add a value to a property list for a String or Boolean type of value creating the propertyDescriptor if it does not exist
      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      value - Th value to be set. Must not be null.
      Throws:
      org.spdx.core.SpdxInvalidTypeException - on invalid type
    • removeTypedValueFromList

      public boolean removeTypedValueFromList(org.spdx.storage.PropertyDescriptor propertyDescriptor, org.spdx.core.TypedValue value) throws org.spdx.core.SpdxInvalidTypeException
      Remove a property from a property list if it exists
      Parameters:
      propertyDescriptor - The descriptor for the property.
      value - The value to be removed.
      Returns:
      true if the value was removed, false if the value did not exist.
      Throws:
      org.spdx.core.SpdxInvalidTypeException - for an invalid type
    • removeValueFromList

      public boolean removeValueFromList(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.SpdxInvalidTypeException
      Remove a property from a property list if it exists
      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      value - The value to be removed. Must not be null.
      Returns:
      true if the value was removed, false if the value did not exist.
      Throws:
      org.spdx.core.SpdxInvalidTypeException - on invalid type
    • getValueList

      public Iterator<Object> getValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.SpdxInvalidTypeException
      Retrieve an iterator over the list of values associated with the specified property descriptor
      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      Returns:
      An Iterator over the list of values associated with the property descriptor. If no values exist, an empty iterator is returned.
      Throws:
      org.spdx.core.SpdxInvalidTypeException - If the property is not associated with a list or if the type is invalid.
    • getValue

      public Object getValue(org.spdx.storage.PropertyDescriptor propertyDescriptor)
      Retrieve the value associated with the specified property descriptor
      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      Returns:
      The single value associated with the specified property descriptor, or null if no value exists.
    • removeProperty

      public void removeProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor)
      Remove 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:
      propertyDescriptor - The descriptor for the property. Must not be null.
    • copyValuesFrom

      public void copyValuesFrom(org.spdx.storage.IModelStore store) throws org.spdx.core.InvalidSPDXAnalysisException
      Copy all values for this item from another model store
      Parameters:
      store - The IModelStore from which to copy values. Must not be null.
      Throws:
      org.spdx.core.InvalidSPDXAnalysisException - If an invalid type is encountered during the copy process. This can occur if the values in the source store are not compatible with this item's properties.
    • collectionSize

      public int collectionSize(org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.SpdxInvalidTypeException
      Retrieve the size of the collection associated with the specified property descriptor

      This method calculates the total number of elements in the collection associated with the given property descriptor.

      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      Returns:
      The size of the collection.
      Throws:
      org.spdx.core.SpdxInvalidTypeException - If the type is invalid or if the property is not associated with a collection.
    • collectionContains

      public boolean collectionContains(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.SpdxInvalidTypeException
      Check whether the specified value exists in the collection associated with the given property descriptor

      This method verifies if the provided value is present in the collection of values associated with the specified property descriptor.

      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      value - The value to be checked. Must not be null.
      Returns:
      true if the value exists in the collection; false otherwise.
      Throws:
      org.spdx.core.SpdxInvalidTypeException - If the type is invalid or if the property is not associated with a collection.
    • isCollectionMembersAssignableTo

      public boolean isCollectionMembersAssignableTo(org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz) throws org.spdx.core.ModelRegistryException
      Check whether all members of the collection associated with the specified property descriptor can be assigned to the specified class
      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      clazz - The class to test against. Must not be null.
      Returns:
      true if the property with the propertyDescriptor can be assigned to clazz; false otherwise.
      Throws:
      org.spdx.core.ModelRegistryException - If the model registry is not properly initialized.
    • isPropertyValueAssignableTo

      public boolean isPropertyValueAssignableTo(org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz, String specVersion) throws org.spdx.core.ModelRegistryException
      Check whether the value associated with the specified property descriptor can be assigned to the specified class
      Parameters:
      propertyDescriptor - The descriptor for the property. Must not be null.
      clazz - The class to test against. Must not be null.
      specVersion - The SPDX specification version to use for type resolution.
      Returns:
      true if the property value can be assigned to type clazz for the latest SPDX spec version; false otherwise.
      Throws:
      org.spdx.core.ModelRegistryException - If the model registry is not properly initialized.
    • isCollectionProperty

      public boolean isCollectionProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor)
      Check whether the specified property descriptor is associated with a collection
      Parameters:
      propertyDescriptor - The property descriptor to check. Must not be null.
      Returns:
      true if the property descriptor is associated with a collection; false otherwise.
    • usesId

      public boolean usesId(String elementId)
      Check whether the specified element ID is used as a value in any collection or property
      Parameters:
      elementId - The object URI of the element to check.
      Returns:
      true if the element using the object URI is used as a value in a collection; false otherwise.