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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddValueToCollection(String documentUri, String id, String propertyName, Object value) voidclearValueCollection(String documentUri, String id, String propertyName) voidclose()booleancollectionContains(String documentUri, String id, String propertyName, Object value) intcollectionSize(String documentUri, String id, String propertyName) voidvoiddeSerialize(InputStream stream, boolean overwrite) deSerialize(InputStream stream, boolean overwrite, String documentNamespace) Deserialize an RDF stream without an enclosing documentorg.spdx.storage.IModelStore.IModelStoreLockenterCriticalSection(String documentUri, boolean readLockRequested) booleanjava.util.stream.Stream<org.spdx.library.model.TypedValue>getAllItems(String documentUri, String typeFilter) getCaseSensisitiveId(String documentUri, String caseInsensisitiveId) static StringgetDocumentNamespace(org.apache.jena.rdf.model.Model model) org.spdx.storage.IModelStore.IdTypegetPropertyValueNames(String documentUri, String id) static org.apache.jena.graph.NodegetSpdxDocNode(org.apache.jena.rdf.model.Model model) Optional<org.spdx.library.model.TypedValue>getTypedValue(String documentUri, String id) booleanisCollectionMembersAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) booleanisCollectionProperty(String documentUri, String id, String propertyName) booleanisPropertyValueAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) voidleaveCriticalSection(org.spdx.storage.IModelStore.IModelStoreLock lock) listValues(String documentUri, String id, String propertyName) loadModelFromFile(String fileNameOrUrl, boolean overwrite) Load a document from a file or URLvoidremoveProperty(String documentUri, String id, String propertyName) booleanremoveValueFromCollection(String documentUri, String id, String propertyName, Object value) voidserialize(String documentUri, OutputStream stream) voidsetOutputFormat(OutputFormat outputFormat) void
-
Constructor Details
-
RdfStore
public RdfStore()
-
-
Method Details
-
getOutputFormat
- Returns:
- the outputFormat
-
setOutputFormat
- Parameters:
outputFormat- the outputFormat to set
-
exists
- Specified by:
existsin interfaceorg.spdx.storage.IModelStore
-
getIdType
- Specified by:
getIdTypein interfaceorg.spdx.storage.IModelStore
-
create
public void create(String documentUri, String id, String type) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
createin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
getPropertyValueNames
public List<String> getPropertyValueNames(String documentUri, String id) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
getPropertyValueNamesin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
setValue
public void setValue(String documentUri, String id, String propertyName, Object value) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
setValuein interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
getValue
public Optional<Object> getValue(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
getValuein interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
getNextId
public String getNextId(org.spdx.storage.IModelStore.IdType idType, String documentUri) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
getNextIdin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
removeProperty
public void removeProperty(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
removePropertyin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
getDocumentUris
- Specified by:
getDocumentUrisin interfaceorg.spdx.storage.IModelStore
-
getAllItems
public java.util.stream.Stream<org.spdx.library.model.TypedValue> getAllItems(String documentUri, String typeFilter) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
getAllItemsin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
removeValueFromCollection
public boolean removeValueFromCollection(String documentUri, String id, String propertyName, Object value) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
removeValueFromCollectionin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
collectionSize
public int collectionSize(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
collectionSizein interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
collectionContains
public boolean collectionContains(String documentUri, String id, String propertyName, Object value) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
collectionContainsin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
clearValueCollection
public void clearValueCollection(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
clearValueCollectionin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
addValueToCollection
public boolean addValueToCollection(String documentUri, String id, String propertyName, Object value) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
addValueToCollectionin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
listValues
public Iterator<Object> listValues(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
listValuesin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
isCollectionMembersAssignableTo
public boolean isCollectionMembersAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
isCollectionMembersAssignableToin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
isPropertyValueAssignableTo
public boolean isPropertyValueAssignableTo(String documentUri, String id, String propertyName, Class<?> clazz) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
isPropertyValueAssignableToin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
isCollectionProperty
public boolean isCollectionProperty(String documentUri, String id, String propertyName) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
isCollectionPropertyin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.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(String documentUri, boolean readLockRequested) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
enterCriticalSectionin interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
loadModelFromFile
public String loadModelFromFile(String fileNameOrUrl, boolean overwrite) throws org.spdx.library.InvalidSPDXAnalysisException, IOException Load a document from a file or URL- Parameters:
fileNameOrUrl-overwrite- if true, overwrite any existing documents with the same document URI- Returns:
- the DocumentURI of the SPDX document
- Throws:
org.spdx.library.InvalidSPDXAnalysisExceptionIOException
-
getSpdxDocNode
public static org.apache.jena.graph.Node getSpdxDocNode(org.apache.jena.rdf.model.Model model) - Returns:
- the spdx doc node from the model
-
getDocumentNamespace
public static String getDocumentNamespace(org.apache.jena.rdf.model.Model model) throws org.spdx.library.InvalidSPDXAnalysisException - Parameters:
model- model containing a single document- Returns:
- the document namespace for the document stored in the model
- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
serialize
public void serialize(String documentUri, OutputStream stream) throws org.spdx.library.InvalidSPDXAnalysisException, IOException - Specified by:
serializein interfaceorg.spdx.storage.ISerializableModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisExceptionIOException
-
deSerialize
public String deSerialize(InputStream stream, boolean overwrite) throws org.spdx.library.InvalidSPDXAnalysisException, IOException - Specified by:
deSerializein interfaceorg.spdx.storage.ISerializableModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisExceptionIOException
-
deSerialize
public String deSerialize(InputStream stream, boolean overwrite, String documentNamespace) throws org.spdx.library.InvalidSPDXAnalysisException, IOException Deserialize an RDF stream without an enclosing document- Parameters:
stream-documentNamespace-- Returns:
- the documentNamespace
- Throws:
org.spdx.library.InvalidSPDXAnalysisExceptionIOException
-
getCaseSensisitiveId
- Specified by:
getCaseSensisitiveIdin interfaceorg.spdx.storage.IModelStore
-
getTypedValue
public Optional<org.spdx.library.model.TypedValue> getTypedValue(String documentUri, String id) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
getTypedValuein interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
delete
public void delete(String documentUri, String id) throws org.spdx.library.InvalidSPDXAnalysisException - Specified by:
deletein interfaceorg.spdx.storage.IModelStore- Throws:
org.spdx.library.InvalidSPDXAnalysisException
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-