001: /*
002: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
003: *
004: * Licensed under the Aduna BSD-style license.
005: */
006: package org.openrdf.sail.inferencer;
007:
008: import info.aduna.iteration.CloseableIteration;
009:
010: import org.openrdf.model.Resource;
011: import org.openrdf.model.Statement;
012: import org.openrdf.model.URI;
013: import org.openrdf.model.Value;
014: import org.openrdf.query.BindingSet;
015: import org.openrdf.query.Dataset;
016: import org.openrdf.query.QueryEvaluationException;
017: import org.openrdf.query.algebra.TupleExpr;
018: import org.openrdf.sail.SailException;
019: import org.openrdf.sail.helpers.SailConnectionWrapper;
020:
021: /**
022: * An extension of ConnectionWrapper that implements the
023: * {@link InferencerConnection} interface.
024: *
025: * @author Arjohn Kampman
026: */
027: public class InferencerConnectionWrapper extends SailConnectionWrapper
028: implements InferencerConnection {
029:
030: /*--------------*
031: * Constructors *
032: *--------------*/
033:
034: /**
035: * Creates a new InferencerConnectionWrapper object that wraps the supplied
036: * transaction.
037: */
038: public InferencerConnectionWrapper(InferencerConnection con) {
039: super (con);
040: }
041:
042: /*---------*
043: * Methods *
044: *---------*/
045:
046: /**
047: * Gets the connection that is wrapped by this object.
048: *
049: * @return The connection that was supplied to the constructor of this class.
050: */
051: @Override
052: protected InferencerConnection getWrappedConnection() {
053: return (InferencerConnection) super .getWrappedConnection();
054: }
055:
056: public boolean addInferredStatement(Resource subj, URI pred,
057: Value obj, Resource... contexts) throws SailException {
058: return getWrappedConnection().addInferredStatement(subj, pred,
059: obj, contexts);
060: }
061:
062: public boolean removeInferredStatement(Resource subj, URI pred,
063: Value obj, Resource... contexts) throws SailException {
064: return getWrappedConnection().removeInferredStatement(subj,
065: pred, obj, contexts);
066: }
067:
068: public void clearInferred(Resource... contexts)
069: throws SailException {
070: getWrappedConnection().clearInferred(contexts);
071: }
072:
073: public void flushUpdates() throws SailException {
074: getWrappedConnection().flushUpdates();
075: }
076:
077: /**
078: * Calls {@link #flushUpdates()} before forwarding the call to the wrapped
079: * connection.
080: */
081: @Override
082: public void commit() throws SailException {
083: flushUpdates();
084: super .commit();
085: }
086:
087: /**
088: * Calls {@link #flushUpdates()} before forwarding the call to the wrapped
089: * connection.
090: */
091: @Override
092: public CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate(
093: TupleExpr tupleExpr, Dataset dataset, BindingSet bindings,
094: boolean includeInferred) throws SailException {
095: flushUpdates();
096: return super .evaluate(tupleExpr, dataset, bindings,
097: includeInferred);
098: }
099:
100: /**
101: * Calls {@link #flushUpdates()} before forwarding the call to the wrapped
102: * connection.
103: */
104: @Override
105: public CloseableIteration<? extends Resource, SailException> getContextIDs()
106: throws SailException {
107: flushUpdates();
108: return super .getContextIDs();
109: }
110:
111: /**
112: * Calls {@link #flushUpdates()} before forwarding the call to the wrapped
113: * connection.
114: */
115: @Override
116: public CloseableIteration<? extends Statement, SailException> getStatements(
117: Resource subj, URI pred, Value obj,
118: boolean includeInferred, Resource... contexts)
119: throws SailException {
120: flushUpdates();
121: return super .getStatements(subj, pred, obj, includeInferred,
122: contexts);
123: }
124:
125: /**
126: * Calls {@link #flushUpdates()} before forwarding the call to the wrapped
127: * connection.
128: */
129: @Override
130: public long size(Resource... contexts) throws SailException {
131: flushUpdates();
132: return super.size(contexts);
133: }
134: }
|