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
ConstructorsConstructorDescriptionStoredTypedItem(String objectUri, String type, String specVersion) Construct a newStoredTypedItemwith the specified object URI, type, and specification version -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddValueToList(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 existvoidclearPropertyValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor) Set the value list for the property to an empty list creating the propertyDescriptor if it does not existbooleancollectionContains(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) Check whether the specified value exists in the collection associated with the given property descriptorintcollectionSize(org.spdx.storage.PropertyDescriptor propertyDescriptor) Retrieve the size of the collection associated with the specified property descriptorvoidcopyValuesFrom(org.spdx.storage.IModelStore store) Copy all values for this item from another model storeintDecrement the reference count for this stored type itemList<org.spdx.storage.PropertyDescriptor> Retrieve the property descriptors for all properties that have a valueintRetrieve the current reference count for this stored itemgetValue(org.spdx.storage.PropertyDescriptor propertyDescriptor) Retrieve the value associated with the specified property descriptorgetValueList(org.spdx.storage.PropertyDescriptor propertyDescriptor) Retrieve an iterator over the list of values associated with the specified property descriptorintIncrement the reference count for this stored type item - the number of times this item is referencedbooleanisCollectionMembersAssignableTo(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 classbooleanisCollectionProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor) Check whether the specified property descriptor is associated with a collectionbooleanisPropertyValueAssignableTo(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 classvoidremoveProperty(org.spdx.storage.PropertyDescriptor propertyDescriptor) Remove a property from the document for the given ID if the property existsbooleanremoveTypedValueFromList(org.spdx.storage.PropertyDescriptor propertyDescriptor, org.spdx.core.TypedValue value) Remove a property from a property list if it existsbooleanremoveValueFromList(org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) Remove a property from a property list if it existsvoidSet the value for the specified property descriptorbooleanCheck whether the specified element ID is used as a value in any collection or propertyMethods inherited from class org.spdx.core.TypedValue
equals, getObjectUri, getSpecVersion, getType, hashCode, toString
-
Constructor Details
-
StoredTypedItem
public StoredTypedItem(String objectUri, String type, String specVersion) throws org.spdx.core.InvalidSPDXAnalysisException Construct a newStoredTypedItemwith the specified object URI, type, and specification versionThis 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
Retrieve the property descriptors for all properties that have a valueThis method iterates through the stored properties and collects the descriptors for all properties that currently have an associated value.
- Returns:
- An unmodifiable
ListofPropertyDescriptorobjects 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.SpdxInvalidTypeExceptionDecrement 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 benull.value- The value to be set. Must not benull.- 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 benull.- 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 benull.value- Th value to be set. Must not benull.- 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:
trueif the value was removed,falseif 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 benull.value- The value to be removed. Must not benull.- Returns:
trueif the value was removed,falseif 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 benull.- Returns:
- An
Iteratorover 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
Retrieve the value associated with the specified property descriptor- Parameters:
propertyDescriptor- The descriptor for the property. Must not benull.- Returns:
- The single value associated with the specified property descriptor, or
nullif 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 existsDoes not raise any exception if the propertyDescriptor does not exist.
- Parameters:
propertyDescriptor- The descriptor for the property. Must not benull.
-
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- TheIModelStorefrom which to copy values. Must not benull.- 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 descriptorThis 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 benull.- 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 descriptorThis 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 benull.value- The value to be checked. Must not benull.- Returns:
trueif the value exists in the collection;falseotherwise.- 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 benull.clazz- The class to test against. Must not benull.- Returns:
trueif the property with thepropertyDescriptorcan be assigned toclazz;falseotherwise.- 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 benull.clazz- The class to test against. Must not benull.specVersion- The SPDX specification version to use for type resolution.- Returns:
trueif the property value can be assigned to typeclazzfor the latest SPDX spec version;falseotherwise.- 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 benull.- Returns:
trueif the property descriptor is associated with a collection;falseotherwise.
-
usesId
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:
trueif the element using the object URI is used as a value in a collection;falseotherwise.
-