Class BaseTripleStore
Abstract Base Class for a Triple Store.
Inherited Members
Namespace: VDS.RDF
Assembly: dotNetRdf.dll
Syntax
public abstract class BaseTripleStore : ITripleStore, IDisposable
Constructors
| Edit this page View SourceBaseTripleStore(BaseGraphCollection)
Creates a new Base Triple Store.
Declaration
protected BaseTripleStore(BaseGraphCollection graphCollection)
Parameters
Type | Name | Description |
---|---|---|
BaseGraphCollection | graphCollection | Graph Collection to use. |
Fields
| Edit this page View Source_graphs
Collection of Graphs that comprise the Triple Store.
Declaration
protected BaseGraphCollection _graphs
Field Value
Type | Description |
---|---|
BaseGraphCollection |
Properties
| Edit this page View SourceGraphs
Gets the Collection of Graphs that comprise this Triple Store.
Declaration
public BaseGraphCollection Graphs { get; }
Property Value
Type | Description |
---|---|
BaseGraphCollection |
IsEmpty
Gets whether the Triple Store is empty.
Declaration
public virtual bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool |
this[Uri?]
Gets the Graph with the given URI.
Declaration
[Obsolete("Replaced by this[IRefNode]")]
public IGraph this[Uri? graphUri] { get; }
Parameters
Type | Name | Description |
---|---|---|
Uri | graphUri | Graph URI. |
Property Value
Type | Description |
---|---|
IGraph |
this[IRefNode?]
Gets a graph from the triple store.
Declaration
public IGraph this[IRefNode? graphName] { get; }
Parameters
Type | Name | Description |
---|---|---|
IRefNode | graphName | The name of the graph to be retrieved. May be null to retrieve the default (unnamed) graph. |
Property Value
Type | Description |
---|---|
IGraph |
Quads
Gets all the Quads in the Triple Store which are currently loaded in memory.
Declaration
public IEnumerable<Quad> Quads { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Quad> |
Remarks
Since a Triple Store object may represent only a snapshot of the underlying Store evaluating this enumerator may only return some of the Quads in the Store and may depending on specific Triple Store return nothing.
Triples
Gets all the Triples in the Triple Store.
Declaration
public IEnumerable<Triple> Triples { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Triple> |
UriFactory
Get the preferred URI factory to use when creating URIs in this store.
Declaration
public abstract IUriFactory UriFactory { get; }
Property Value
Type | Description |
---|---|
IUriFactory |
Methods
| Edit this page View SourceAdd(IGraph)
Adds a Graph into the Triple Store.
Declaration
public virtual bool Add(IGraph g)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to add. |
Returns
Type | Description |
---|---|
bool |
Add(IGraph, bool)
Adds a Graph into the Triple Store using the chosen Merging Behaviour.
Declaration
public virtual bool Add(IGraph g, bool mergeIfExists)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to add. |
bool | mergeIfExists | Whether the Graph should be merged with an existing Graph with the same Base Uri. |
Returns
Type | Description |
---|---|
bool |
Add(IRefNode)
Add a new empty graph with the specified name to the triple store
Declaration
public virtual bool Add(IRefNode graphName)
Parameters
Type | Name | Description |
---|---|---|
IRefNode | graphName | The name of the graph to add. |
Returns
Type | Description |
---|---|
bool | True if the execution resulted in a new graph being added to the triplestore, false otherwise. |
AddFromUri(Uri)
Adds a Graph into the Triple Store which is retrieved from the given Uri.
Declaration
public virtual bool AddFromUri(Uri graphUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | graphUri | Uri of the Graph to load. |
Returns
Type | Description |
---|---|
bool |
AddFromUri(Uri, bool)
Adds a Graph into the Triple Store which is retrieved from the given Uri using the chosen Merging Behaviour.
Declaration
public virtual bool AddFromUri(Uri graphUri, bool mergeIfExists)
Parameters
Type | Name | Description |
---|---|---|
Uri | graphUri | Graph to add. |
bool | mergeIfExists | Whether the Graph should be merged with an existing Graph with the same Base Uri. |
Returns
Type | Description |
---|---|
bool |
AddFromUri(Uri, bool, Loader)
Adds a Graph into the Triple Store which is retrieved from the given Uri using the chosen Merging Behaviour.
Declaration
public virtual bool AddFromUri(Uri graphUri, bool mergeIfExists, Loader loader)
Parameters
Type | Name | Description |
---|---|---|
Uri | graphUri | Graph to add. |
bool | mergeIfExists | Whether the Graph should be merged with an existing Graph with the same Base Uri. |
Loader | loader | The loader to use to retrieve and parse remote data. |
Returns
Type | Description |
---|---|
bool |
Assert(Quad)
Assert a quad in the triple store.
Declaration
public void Assert(Quad quad)
Parameters
Type | Name | Description |
---|---|---|
Quad | quad | The quad to be added. |
Remarks
If the quad's graph is not currently in the triple store, a new graph will be added.
AttachEventHandlers(IGraph)
Helper method which attaches the Triple Store's Event Handlers to the relevant events of a Graph.
Declaration
protected void AttachEventHandlers(IGraph g)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph. |
DetachEventHandlers(IGraph)
Helper method which detaches the Triple Store's Event Handlers from the relevant events of a Graph.
Declaration
protected void DetachEventHandlers(IGraph g)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g |
Dispose()
Disposes of the Triple Store.
Declaration
public abstract void Dispose()
Remarks
Derived classes must override this to implement required disposal actions.
GetQuads(INode?, INode?, INode?, IRefNode?, bool)
Return an enumeration of all quads in the store that match the specified subject, predicate, object and/or graph.
Declaration
public IEnumerable<Quad> GetQuads(INode? s = null, INode? p = null, INode? o = null, IRefNode? g = null, bool allGraphs = true)
Parameters
Type | Name | Description |
---|---|---|
INode | s | The subject node to match. Null matches all subject nodes. |
INode | p | The predicate node to match. Null matches all predicate nodes. |
INode | o | The object node to match. Null matches all object nodes. |
IRefNode | g | The graph to match. Null matches all graphs if |
bool | allGraphs |
Returns
Type | Description |
---|---|
IEnumerable<Quad> |
GetTriplesFromGraph(IGraph, INode?, INode?, INode?)
Returns an enumeration of the Triples in the specified graph that match the specified node filters.
Declaration
protected virtual IEnumerable<Triple> GetTriplesFromGraph(IGraph graph, INode? s, INode? p, INode? o)
Parameters
Type | Name | Description |
---|---|---|
IGraph | graph | The graph to return triples from. |
INode | s | The subject node to filter on, or null to match all subject nodes. |
INode | p | The predicate node to filter on, or null to match all predicate nodes. |
INode | o | The object node to filter on, or null to match all object nodes. |
Returns
Type | Description |
---|---|
IEnumerable<Triple> | An enumeration of the triples that match the specified filter. |
HasGraph(Uri)
Checks whether a Graph with the given Base Uri exists in the Triple Store.
Declaration
[Obsolete("Replaced by HasGraph(IRefNode)")]
public bool HasGraph(Uri graphUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | graphUri | Graph Uri. |
Returns
Type | Description |
---|---|
bool | True if the Graph exists in the Triple Store. |
HasGraph(IRefNode?)
Checks whether the graph with the given name is in this triple store.
Declaration
public bool HasGraph(IRefNode? graphName)
Parameters
Type | Name | Description |
---|---|---|
IRefNode | graphName | The name of the graph to check for. |
Returns
Type | Description |
---|---|
bool | True if this store contains a graph with the specified name, false otherwise. |
Remarks
Pass null forgraphName
to check for the default (unnamed) graph.
OnGraphAdded(object, GraphEventArgs)
Event Handler which handles the Graph Added event from the underlying Graph Collection and raises the Triple Store's Graph Added event.
Declaration
protected virtual void OnGraphAdded(object sender, GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
object | sender | Sender. |
GraphEventArgs | args | Graph Event Arguments. |
Remarks
Override this method if your Triple Store implementation wishes to take additional actions when a Graph is added to the Store.
OnGraphChanged(object, GraphEventArgs)
Event Handler which handles the Changed event of the contained Graphs by raising the Triple Store's Graph Changed event.
Declaration
protected virtual void OnGraphChanged(object sender, GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
object | sender | Sender. |
GraphEventArgs | args | Graph Event Arguments. |
OnGraphCleared(object, GraphEventArgs)
Event Handler which handles the Cleared event of the contained Graphs by raising the Triple Stores's Graph Cleared event.
Declaration
protected virtual void OnGraphCleared(object sender, GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
object | sender | Sender. |
GraphEventArgs | args | Graph Event Arguments. |
OnGraphMerged(object, GraphEventArgs)
Event Handler which handles the Merged event of the contained Graphs by raising the Triple Store's Graph Merged event.
Declaration
protected virtual void OnGraphMerged(object sender, GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
object | sender | Sender. |
GraphEventArgs | args | Graph Event Arguments. |
OnGraphRemoved(object, GraphEventArgs)
Event Handler which handles the Graph Removed event from the underlying Graph Collection and raises the Triple Stores's Graph Removed event.
Declaration
protected virtual void OnGraphRemoved(object sender, GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
object | sender | Sender. |
GraphEventArgs | args | Graph Event Arguments. |
RaiseGraphAdded(GraphEventArgs)
Helper method for raising the Graph Added event manually.
Declaration
protected void RaiseGraphAdded(GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
GraphEventArgs | args | Graph Event Arguments. |
RaiseGraphAdded(IGraph)
Helper method for raising the Graph Added event manually.
Declaration
protected void RaiseGraphAdded(IGraph g)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph. |
RaiseGraphChanged(GraphEventArgs)
Helper method for raising the Graph Changed event manually.
Declaration
protected void RaiseGraphChanged(GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
GraphEventArgs | args | Graph Event Arguments. |
RaiseGraphChanged(IGraph)
Helper method for raising the Graph Changed event manually.
Declaration
protected void RaiseGraphChanged(IGraph g)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph. |
RaiseGraphCleared(GraphEventArgs)
Helper method for raising the Graph Cleared event manually.
Declaration
protected void RaiseGraphCleared(GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
GraphEventArgs | args | Graph Event Arguments. |
RaiseGraphMerged(GraphEventArgs)
Helper method for raising the Graph Merged event manually.
Declaration
protected void RaiseGraphMerged(GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
GraphEventArgs | args | Graph Event Arguments. |
RaiseGraphRemoved(GraphEventArgs)
Helper method for raising the Graph Removed event manually.
Declaration
protected void RaiseGraphRemoved(GraphEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
GraphEventArgs | args | Graph Event Arguments. |
RaiseGraphRemoved(IGraph)
Helper method for raising the Graph Removed event manually.
Declaration
protected void RaiseGraphRemoved(IGraph g)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph. |
Remove(Uri)
Removes a Graph from the Triple Store.
Declaration
[Obsolete("Replaced by Remove(IRefNode)")]
public virtual bool Remove(Uri graphUri)
Parameters
Type | Name | Description |
---|---|---|
Uri | graphUri | Uri of the Graph to Remove. |
Returns
Type | Description |
---|---|
bool |
Remove(IRefNode)
Removes a graph from the triple store.
Declaration
public virtual bool Remove(IRefNode graphName)
Parameters
Type | Name | Description |
---|---|---|
IRefNode | graphName | The name of the graph to remove. |
Returns
Type | Description |
---|---|
bool | True if the operation removed a graph, false if no matching graph was found to remove. |
Retract(Quad)
Remove a quad from the triple store.
Declaration
public void Retract(Quad quad)
Parameters
Type | Name | Description |
---|---|---|
Quad | quad | The quad to be removed. |
Remarks
If the quad's graph is not currently in the triple store, this operation will make no modification to the triple store. Otherwise it will invoke the Retract method on the graph.
Events
| Edit this page View SourceGraphAdded
Event which is raised when a Graph is added
Declaration
public event TripleStoreEventHandler GraphAdded
Event Type
Type | Description |
---|---|
TripleStoreEventHandler |
GraphChanged
Event which is raised when a Graphs contents changes
Declaration
public event TripleStoreEventHandler GraphChanged
Event Type
Type | Description |
---|---|
TripleStoreEventHandler |
GraphCleared
Event which is raised when a Graph is cleared
Declaration
public event TripleStoreEventHandler GraphCleared
Event Type
Type | Description |
---|---|
TripleStoreEventHandler |
GraphMerged
Event which is raised when a Graph has a merge operation performed on it
Declaration
public event TripleStoreEventHandler GraphMerged
Event Type
Type | Description |
---|---|
TripleStoreEventHandler |
GraphRemoved
Event which is raised when a Graph is removed
Declaration
public event TripleStoreEventHandler GraphRemoved
Event Type
Type | Description |
---|---|
TripleStoreEventHandler |