Package org.spdx.spdxRdfStore
Class RdfStore
java.lang.Object
org.spdx.spdxRdfStore.RdfStore
- All Implemented Interfaces:
AutoCloseable,org.spdx.storage.IModelStore,org.spdx.storage.ISerializableModelStore
public class RdfStore
extends Object
implements org.spdx.storage.IModelStore, org.spdx.storage.ISerializableModelStore
Model Store implemented using RDF
- Author:
- Gary O'Neall
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spdx.storage.IModelStore
org.spdx.storage.IModelStore.IdType, org.spdx.storage.IModelStore.IModelStoreLock, org.spdx.storage.IModelStore.ModelUpdate -
Constructor Summary
ConstructorsConstructorDescriptionRdfStore()Creates an uninitialized RDF store - the documentUri must be set or a stream deserialized before any other methods are calledRdfStore(InputStream stream) Create an RDF store and initialize it with an SPDX document deserialized from stream Note that the stream must contain one and only one SPDX document in SPDX version 2.X formatRdfStore(InputStream stream, String documentUri) Create an RDF store and initialize it with a data deserialized from stream using the documentUri for ID prefixes -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddValueToCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) voidclearValueCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) voidclose()booleancollectionContains(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) intcollectionSize(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) voidcreate(org.spdx.core.TypedValue typedValue) voidorg.spdx.library.model.v2.SpdxDocumentdeSerialize(InputStream stream, boolean overwrite) voiddeSerialize(InputStream stream, boolean overwrite, String documentNamespace) Deserialize an RDF stream without an enclosing documentorg.spdx.storage.IModelStore.IModelStoreLockenterCriticalSection(boolean readLockRequested) booleanStream<org.spdx.core.TypedValue> getAllItems(String prefix, String typeFilter) getCaseSensitiveId(String documentUri, String caseInsensisitiveId) getDocumentNamespaces(org.apache.jena.rdf.model.Model model) org.spdx.storage.IModelStore.IdTypegetNextId(org.spdx.storage.IModelStore.IdType idType) List<org.spdx.storage.PropertyDescriptor> getPropertyValueDescriptors(String objectUri) static List<org.apache.jena.graph.Node> getSpdxDocNodes(org.apache.jena.rdf.model.Model model) Optional<org.spdx.core.TypedValue> getTypedValue(String objectUri) booleanbooleanisCollectionMembersAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz) booleanisCollectionProperty(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) booleanbooleanisPropertyValueAssignableTo(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Class<?> clazz, String specVersion) voidleaveCriticalSection(org.spdx.storage.IModelStore.IModelStoreLock lock) listValues(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor) loadModelFromFile(String fileNameOrUrl, boolean overwrite) Load a document from a file or URLvoidremoveProperty(String objectUri, org.spdx.storage.PropertyDescriptor prop) booleanremoveValueFromCollection(String objectUri, org.spdx.storage.PropertyDescriptor propertyDescriptor, Object value) voidserialize(OutputStream stream) voidserialize(OutputStream stream, org.spdx.core.CoreModelObject spdxDocument) voidsetDocumentUri(String documentUri, boolean overwrite) voidsetDontStoreLicenseDetails(boolean dontStoreLicenseDetails) voidsetOutputFormat(OutputFormat outputFormat) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.spdx.storage.IModelStore
getCaseSensisitiveId
-
Constructor Details
-
RdfStore
Create an RDF store and initialize it with an SPDX document deserialized from stream Note that the stream must contain one and only one SPDX document in SPDX version 2.X format- Parameters:
stream- input stream of a model- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-
RdfStore
public RdfStore()Creates an uninitialized RDF store - the documentUri must be set or a stream deserialized before any other methods are called -
RdfStore
public RdfStore(InputStream stream, String documentUri) throws org.spdx.core.InvalidSPDXAnalysisException Create an RDF store and initialize it with a data deserialized from stream using the documentUri for ID prefixes- Parameters:
stream- stream of an RDF model- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-
RdfStore
- Parameters:
documentUri- URI for the SPDX document used in this store
-
-
Method Details
-
getOutputFormat
- Returns:
- the outputFormat
-
getDocumentUri
- Returns:
- the document URI
-
setDocumentUri
public void setDocumentUri(@Nullable String documentUri, boolean overwrite) throws org.spdx.core.InvalidSPDXAnalysisException - Parameters:
documentUri- document URI to setoverwrite- setting a different document URI will overwrite an existing model - this flag will allow it to be overwritten- Throws:
org.spdx.core.InvalidSPDXAnalysisException- if the document URI already exists and override is set to false
-
setOutputFormat
- Parameters:
outputFormat- the outputFormat to set
-
isDontStoreLicenseDetails
public boolean isDontStoreLicenseDetails()- Returns:
- the dontStoreLicenseDetails - if true, listed license properties will not be stored in the RDF store
-
setDontStoreLicenseDetails
public void setDontStoreLicenseDetails(boolean dontStoreLicenseDetails) - Parameters:
dontStoreLicenseDetails- the dontStoreLicenseDetails to set - if true, listed license properties will not be stored in the RDF store
-
exists
- Specified by:
existsin interfaceorg.spdx.storage.IModelStore
-
isAnon
- Specified by:
isAnonin interfaceorg.spdx.storage.IModelStore
-
getIdType
- Specified by:
getIdTypein interfaceorg.spdx.storage.IModelStore
-
create
public void create(org.spdx.core.TypedValue typedValue) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
createin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getPropertyValueDescriptors
public List<org.spdx.storage.PropertyDescriptor> getPropertyValueDescriptors(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
getPropertyValueDescriptorsin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
setValue
public void setValue(String objectUri, org.spdx.storage.PropertyDescriptor prop, Object value) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
setValuein interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getValue
public Optional<Object> getValue(String objectUri, org.spdx.storage.PropertyDescriptor prop) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
getValuein 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:
getNextIdin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
removeProperty
public void removeProperty(String objectUri, org.spdx.storage.PropertyDescriptor prop) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
removePropertyin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
getAllItems
public Stream<org.spdx.core.TypedValue> getAllItems(@Nullable String prefix, String typeFilter) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
getAllItemsin 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:
removeValueFromCollectionin 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:
collectionSizein 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:
collectionContainsin 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:
clearValueCollectionin 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:
addValueToCollectionin 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:
listValuesin 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:
isCollectionMembersAssignableToin 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:
isPropertyValueAssignableToin 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:
isCollectionPropertyin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
leaveCriticalSection
public void leaveCriticalSection(org.spdx.storage.IModelStore.IModelStoreLock lock) - Specified by:
leaveCriticalSectionin interfaceorg.spdx.storage.IModelStore
-
enterCriticalSection
public org.spdx.storage.IModelStore.IModelStoreLock enterCriticalSection(boolean readLockRequested) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
enterCriticalSectionin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
loadModelFromFile
public String loadModelFromFile(String fileNameOrUrl, boolean overwrite) throws org.spdx.core.InvalidSPDXAnalysisException, IOException Load a document from a file or URL- Parameters:
fileNameOrUrl- file name or URL of a serialized RDF modeloverwrite- if true, overwrite any existing documents with the same document URI- Returns:
- the DocumentURI of the SPDX document
- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errorsIOException- on IO error
-
getSpdxDocNodes
public static List<org.apache.jena.graph.Node> getSpdxDocNodes(org.apache.jena.rdf.model.Model model) - Returns:
- the spdx doc nodes from the model
-
getDocumentNamespaces
public static List<String> getDocumentNamespaces(org.apache.jena.rdf.model.Model model) throws org.spdx.core.InvalidSPDXAnalysisException - Parameters:
model- model containing a single document- Returns:
- the document namespace for the document stored in the model
- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-
serialize
- Specified by:
serializein interfaceorg.spdx.storage.ISerializableModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
serialize
public void serialize(OutputStream stream, @Nullable org.spdx.core.CoreModelObject spdxDocument) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
serializein interfaceorg.spdx.storage.ISerializableModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
deSerialize
public org.spdx.library.model.v2.SpdxDocument deSerialize(InputStream stream, boolean overwrite) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
deSerializein interfaceorg.spdx.storage.ISerializableModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
deSerialize
public void deSerialize(InputStream stream, boolean overwrite, String documentNamespace) throws org.spdx.core.InvalidSPDXAnalysisException Deserialize an RDF stream without an enclosing document- Parameters:
stream- stream containing the SPDX datadocumentNamespace- document namespace to use- Throws:
org.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing errors
-
getCaseSensitiveId
- Specified by:
getCaseSensitiveIdin interfaceorg.spdx.storage.IModelStore
-
getTypedValue
public Optional<org.spdx.core.TypedValue> getTypedValue(String objectUri) throws org.spdx.core.InvalidSPDXAnalysisException - Specified by:
getTypedValuein interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
delete
- Specified by:
deletein interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.core.InvalidSPDXAnalysisException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-