Package org.spdx.storage.simple
Class InMemSpdxStore
- java.lang.Object
-
- org.spdx.storage.simple.InMemSpdxStore
-
- All Implemented Interfaces:
AutoCloseable
,org.spdx.storage.IModelStore
public class InMemSpdxStore extends Object implements org.spdx.storage.IModelStore
- Author:
- Gary O'Neall
In memory implementation of an SPDX store.
This implementation primarily uses
ConcurrentHashMaps
. It is designed to be thread-safe and low CPU utilization. It may use significant amounts of memory for larger SPDX documents.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ANON_PREFIX
Prefix for anonymous idsstatic Pattern
LICENSE_ID_PATTERN_GENERATED
Pattern for the generated license IDprotected Map<String,StoredTypedItem>
typedValueMap
Map of property object URI's to typed value items
-
Constructor Summary
Constructors Constructor Description InMemSpdxStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addValueToCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)
void
clear()
Remove all existing elements, properties, and valuesvoid
clearValueCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor)
void
close()
boolean
collectionContains(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)
int
collectionSize(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor)
void
create(org.spdx.core.TypedValue typedValue)
void
delete(String objectUri)
org.spdx.storage.IModelStore.IModelStoreLock
enterCriticalSection(boolean readLockRequested)
boolean
exists(String objectUri)
Stream<org.spdx.core.TypedValue>
getAllItems(String nameSpace, String typeFilter)
Optional<String>
getCaseSensisitiveId(String nameSpace, String caseInsensisitiveId)
org.spdx.storage.IModelStore.IdType
getIdType(String objectUri)
protected StoredTypedItem
getItem(String objectUri)
Gets the item from the hashmapString
getNextId(org.spdx.storage.IModelStore.IdType idType)
List<org.spdx.storage.PropertyDescriptor>
getPropertyValueDescriptors(String objectUri)
Optional<org.spdx.core.TypedValue>
getTypedValue(String objectUri)
Optional<Object>
getValue(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor)
boolean
isAnon(String objectUri)
boolean
isCollectionMembersAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz)
boolean
isCollectionProperty(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor)
boolean
isPropertyValueAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz, String specVersion)
void
leaveCriticalSection(org.spdx.storage.IModelStore.IModelStoreLock lock)
Iterator<Object>
listValues(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor)
void
removeProperty(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor)
boolean
removeValueFromCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)
void
setValue(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value)
-
-
-
Field Detail
-
LICENSE_ID_PATTERN_GENERATED
public static Pattern LICENSE_ID_PATTERN_GENERATED
Pattern for the generated license ID
-
ANON_PREFIX
public static final String ANON_PREFIX
Prefix for anonymous ids- See Also:
- Constant Field Values
-
typedValueMap
protected Map<String,StoredTypedItem> typedValueMap
Map of property object URI's to typed value items
-
-
Method Detail
-
exists
public boolean exists(String objectUri)
- Specified by:
exists
in interfaceorg.spdx.storage.IModelStore
-
create
public void create(org.spdx.core.TypedValue typedValue) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
create
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getItem
protected StoredTypedItem getItem(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException
Gets the item from the hashmap- Parameters:
objectUri
- Anonymous or URI ID- Returns:
- the item from the hash map
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getPropertyValueDescriptors
public List<org.spdx.storage.PropertyDescriptor> getPropertyValueDescriptors(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
getPropertyValueDescriptors
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setValue
public void setValue(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
setValue
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
clearValueCollection
public void clearValueCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
clearValueCollection
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
addValueToCollection
public boolean addValueToCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
addValueToCollection
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
removeValueFromCollection
public boolean removeValueFromCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
removeValueFromCollection
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
listValues
public Iterator<Object> listValues(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
listValues
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getValue
public Optional<Object> getValue(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
getValue
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getNextId
public String getNextId(org.spdx.storage.IModelStore.IdType idType) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
getNextId
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
removeProperty
public void removeProperty(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
removeProperty
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getAllItems
public Stream<org.spdx.core.TypedValue> getAllItems(@Nullable String nameSpace, @Nullable String typeFilter) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
getAllItems
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
collectionSize
public int collectionSize(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
collectionSize
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
collectionContains
public boolean collectionContains(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
collectionContains
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
isCollectionMembersAssignableTo
public boolean isCollectionMembersAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
isCollectionMembersAssignableTo
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
isPropertyValueAssignableTo
public boolean isPropertyValueAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz, String specVersion) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
isPropertyValueAssignableTo
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
isCollectionProperty
public boolean isCollectionProperty(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
isCollectionProperty
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
isAnon
public boolean isAnon(String objectUri)
- Specified by:
isAnon
in interfaceorg.spdx.storage.IModelStore
-
getIdType
public org.spdx.storage.IModelStore.IdType getIdType(String objectUri)
- Specified by:
getIdType
in interfaceorg.spdx.storage.IModelStore
-
enterCriticalSection
public org.spdx.storage.IModelStore.IModelStoreLock enterCriticalSection(boolean readLockRequested)
- Specified by:
enterCriticalSection
in interfaceorg.spdx.storage.IModelStore
-
leaveCriticalSection
public void leaveCriticalSection(org.spdx.storage.IModelStore.IModelStoreLock lock)
- Specified by:
leaveCriticalSection
in interfaceorg.spdx.storage.IModelStore
-
getCaseSensisitiveId
public Optional<String> getCaseSensisitiveId(String nameSpace, String caseInsensisitiveId)
- Specified by:
getCaseSensisitiveId
in interfaceorg.spdx.storage.IModelStore
-
getTypedValue
public Optional<org.spdx.core.TypedValue> getTypedValue(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
getTypedValue
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
clear
public void clear()
Remove all existing elements, properties, and values
-
delete
public void delete(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException
- Specified by:
delete
in interfaceorg.spdx.storage.IModelStore
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
-