Class InferencerConnectionWrapper
java.lang.Object
org.eclipse.rdf4j.sail.helpers.SailConnectionWrapper
org.eclipse.rdf4j.sail.helpers.NotifyingSailConnectionWrapper
org.eclipse.rdf4j.sail.inferencer.InferencerConnectionWrapper
- All Implemented Interfaces:
AutoCloseable
,FederatedServiceResolverClient
,ThreadSafetyAware
,InferencerConnection
,NotifyingSailConnection
,SailConnection
- Direct Known Subclasses:
AbstractForwardChainingInferencerConnection
,DedupingInferencerConnection
,SchemaCachingRDFSInferencerConnection
public class InferencerConnectionWrapper
extends NotifyingSailConnectionWrapper
implements InferencerConnection
An extension of ConnectionWrapper that implements the
InferencerConnection
interface.- Author:
- Arjohn Kampman
-
Constructor Summary
ConstructorDescriptionCreates a new InferencerConnectionWrapper object that wraps the supplied transaction. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addInferredStatement
(Resource subj, IRI pred, Value obj, Resource... contexts) Adds an inferred statement to a specific context.void
clearInferred
(Resource... contexts) Removes all inferred statements from the specified/all contexts.void
commit()
CallsflushUpdates()
before forwarding the call to the wrapped connection.CloseableIteration
<? extends BindingSet, QueryEvaluationException> evaluate
(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred) CallsflushUpdates()
before forwarding the call to the wrapped connection.void
flush()
Flushes any pending updates and notify changes to listeners as appropriate.void
Flushes any pending updates to be processed and the resulting changes to be reported to registeredSailConnectionListener
s.CloseableIteration
<? extends Resource, SailException> CallsflushUpdates()
before forwarding the call to the wrapped connection.CloseableIteration
<? extends Statement, SailException> getStatements
(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) CallsflushUpdates()
before forwarding the call to the wrapped connection.Gets the connection that is wrapped by this object.boolean
hasStatement
(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Determines if the store contains any statements from the specified contexts that have a specific subject, predicate and/or object.void
prepare()
CallsflushUpdates()
before forwarding the call to the wrapped connection.boolean
removeInferredStatement
(Resource subj, IRI pred, Value obj, Resource... contexts) Removes an inferred statement from a specific context.long
CallsflushUpdates()
before forwarding the call to the wrapped connection.Methods inherited from class org.eclipse.rdf4j.sail.helpers.NotifyingSailConnectionWrapper
addConnectionListener, removeConnectionListener
Methods inherited from class org.eclipse.rdf4j.sail.helpers.SailConnectionWrapper
addStatement, addStatement, begin, begin, clear, clearNamespaces, close, endUpdate, explain, getFederatedServiceResolver, getNamespace, getNamespaces, isActive, isOpen, pendingRemovals, prepareQuery, removeNamespace, removeStatement, removeStatements, rollback, setFederatedServiceResolver, setNamespace, setTransactionSettings, size, startUpdate, supportsConcurrentReads
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.rdf4j.sail.NotifyingSailConnection
addConnectionListener, removeConnectionListener
Methods inherited from interface org.eclipse.rdf4j.sail.SailConnection
addStatement, addStatement, begin, begin, clear, clearNamespaces, close, endUpdate, explain, getNamespace, getNamespaces, isActive, isOpen, pendingRemovals, prepareQuery, removeNamespace, removeStatement, removeStatements, rollback, setNamespace, setTransactionSettings, startUpdate
-
Constructor Details
-
InferencerConnectionWrapper
Creates a new InferencerConnectionWrapper object that wraps the supplied transaction.
-
-
Method Details
-
getWrappedConnection
Gets the connection that is wrapped by this object.- Overrides:
getWrappedConnection
in classNotifyingSailConnectionWrapper
- Returns:
- The connection that was supplied to the constructor of this class.
-
addInferredStatement
public boolean addInferredStatement(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException Description copied from interface:InferencerConnection
Adds an inferred statement to a specific context.- Specified by:
addInferredStatement
in interfaceInferencerConnection
- Parameters:
subj
- The subject of the statement to add.pred
- The predicate of the statement to add.obj
- The object of the statement to add.contexts
- The context(s) to add the statement to. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.- Throws:
SailException
- If the statement could not be added.
-
removeInferredStatement
public boolean removeInferredStatement(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException Description copied from interface:InferencerConnection
Removes an inferred statement from a specific context.- Specified by:
removeInferredStatement
in interfaceInferencerConnection
- Parameters:
subj
- The subject of the statement that should be removed.pred
- The predicate of the statement that should be removed.obj
- The object of the statement that should be removed.contexts
- The context(s) from which to remove the statements. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.- Throws:
SailException
- If the statement could not be removed.
-
clearInferred
Description copied from interface:InferencerConnection
Removes all inferred statements from the specified/all contexts. If no contexts are specified the method operates on the entire repository.- Specified by:
clearInferred
in interfaceInferencerConnection
- Parameters:
contexts
- The context(s) from which to remove the statements. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.- Throws:
SailException
- If the statements could not be removed.
-
flush
Description copied from interface:SailConnection
Flushes any pending updates and notify changes to listeners as appropriate. This is an optional call; calling or not calling this method should have no effect on the outcome of other calls. This method exists to give the caller more control over the efficiency when callingSailConnection.prepare()
. This method may be called multiple times within the same transaction.- Specified by:
flush
in interfaceSailConnection
- Overrides:
flush
in classSailConnectionWrapper
- Throws:
SailException
- If the updates could not be processed, for example because no transaction is active.
-
flushUpdates
Description copied from interface:InferencerConnection
Flushes any pending updates to be processed and the resulting changes to be reported to registeredSailConnectionListener
s.- Specified by:
flushUpdates
in interfaceInferencerConnection
- Throws:
SailException
- If the updates could not be processed.
-
prepare
CallsflushUpdates()
before forwarding the call to the wrapped connection.- Specified by:
prepare
in interfaceSailConnection
- Overrides:
prepare
in classSailConnectionWrapper
- Throws:
SailException
- If there is an active transaction and it cannot be committed.
-
commit
CallsflushUpdates()
before forwarding the call to the wrapped connection.- Specified by:
commit
in interfaceSailConnection
- Overrides:
commit
in classSailConnectionWrapper
- Throws:
SailException
- If the SailConnection could not be committed.
-
evaluate
public CloseableIteration<? extends BindingSet,QueryEvaluationException> evaluate(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred) throws SailException CallsflushUpdates()
before forwarding the call to the wrapped connection.- Specified by:
evaluate
in interfaceSailConnection
- Overrides:
evaluate
in classSailConnectionWrapper
- Parameters:
tupleExpr
- The tuple expression to evaluate.dataset
- The dataset to use for evaluating the query, null to use the Sail's default dataset.bindings
- A set of input parameters for the query evaluation. The keys reference variable names that should be bound to the value they map to.includeInferred
- Indicates whether inferred triples are to be considered in the query result. If false, no inferred statements are returned; if true, inferred statements are returned if available- Returns:
- The TupleQueryResult.
- Throws:
SailException
- If the Sail object encountered an error or unexpected situation internally.
-
getContextIDs
CallsflushUpdates()
before forwarding the call to the wrapped connection.- Specified by:
getContextIDs
in interfaceSailConnection
- Overrides:
getContextIDs
in classSailConnectionWrapper
- Returns:
- An iterator over the context identifiers, should not contain any duplicates.
- Throws:
SailException
-
hasStatement
public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws SailException Description copied from interface:SailConnection
Determines if the store contains any statements from the specified contexts that have a specific subject, predicate and/or object. All three parameters may be null to indicate wildcards. The includeInferred parameter can be used to control which statements are checked: all statements or only the statements that have been added explicitly.- Specified by:
hasStatement
in interfaceSailConnection
- Overrides:
hasStatement
in classSailConnectionWrapper
- Parameters:
subj
- A Resource specifying the subject, or null for a wildcard.pred
- An IRI specifying the predicate, or null for a wildcard.obj
- A Value specifying the object, or null for a wildcard.includeInferred
- if false, no inferred statements are returned; if true, inferred statements are returned if availablecontexts
- The context(s) to get the data from. Note that this parameter is a vararg and as such is optional. If no contexts are specified the method operates on the entire repository. A null value can be used to match context-less statements.- Returns:
true
iff the store contains any statements matching the supplied criteria,false
otherwise.- Throws:
SailException
- If the Sail object encountered an error or unexpected situation internally.
-
getStatements
public CloseableIteration<? extends Statement,SailException> getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws SailException CallsflushUpdates()
before forwarding the call to the wrapped connection.- Specified by:
getStatements
in interfaceSailConnection
- Overrides:
getStatements
in classSailConnectionWrapper
- Parameters:
subj
- A Resource specifying the subject, or null for a wildcard.pred
- A URI specifying the predicate, or null for a wildcard.obj
- A Value specifying the object, or null for a wildcard.includeInferred
- if false, no inferred statements are returned; if true, inferred statements are returned if availablecontexts
- The context(s) to get the data from. Note that this parameter is a vararg and as such is optional. If no contexts are specified the method operates on the entire repository. A null value can be used to match context-less statements.- Returns:
- The statements matching the specified pattern.
- Throws:
SailException
- If the Sail object encountered an error or unexpected situation internally.
-
size
CallsflushUpdates()
before forwarding the call to the wrapped connection.- Specified by:
size
in interfaceSailConnection
- Overrides:
size
in classSailConnectionWrapper
- Parameters:
contexts
- The context(s) to determine the size of. Note that this parameter is a vararg and as such is optional. If no contexts are specified the method operates on the entire repository. A null value can be used to match context-less statements.- Returns:
- The number of explicit statements in this store, or in the specified context(s).
- Throws:
SailException
-