001: /*
002: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
003: *
004: * Licensed under the Aduna BSD-style license.
005: */
006: package org.openrdf.sail.helpers;
007:
008: import info.aduna.iteration.CloseableIteration;
009:
010: import org.openrdf.model.Namespace;
011: import org.openrdf.model.Resource;
012: import org.openrdf.model.Statement;
013: import org.openrdf.model.URI;
014: import org.openrdf.model.Value;
015: import org.openrdf.query.BindingSet;
016: import org.openrdf.query.Dataset;
017: import org.openrdf.query.QueryEvaluationException;
018: import org.openrdf.query.algebra.TupleExpr;
019: import org.openrdf.sail.SailConnection;
020: import org.openrdf.sail.SailConnectionListener;
021: import org.openrdf.sail.SailException;
022:
023: /**
024: * An implementation of the Transaction interface that wraps another Transaction
025: * object and forwards any method calls to the wrapped transaction.
026: *
027: * @author jeen
028: */
029: public class SailConnectionWrapper implements SailConnection {
030:
031: /*-----------*
032: * Variables *
033: *-----------*/
034:
035: /**
036: * The wrapped SailConnection.
037: */
038: private SailConnection wrappedCon;
039:
040: /*--------------*
041: * Constructors *
042: *--------------*/
043:
044: /**
045: * Creates a new TransactionWrapper object that wraps the supplied
046: * connection.
047: */
048: public SailConnectionWrapper(SailConnection wrappedCon) {
049: this .wrappedCon = wrappedCon;
050: }
051:
052: /*---------*
053: * Methods *
054: *---------*/
055:
056: /**
057: * Gets the Connection that is wrapped by this object.
058: *
059: * @return The SailConnection object that was supplied to the constructor of
060: * this class.
061: */
062: protected SailConnection getWrappedConnection() {
063: return wrappedCon;
064: }
065:
066: public boolean isOpen() throws SailException {
067: return wrappedCon.isOpen();
068: }
069:
070: public void close() throws SailException {
071: wrappedCon.close();
072: }
073:
074: public CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate(
075: TupleExpr tupleExpr, Dataset dataset, BindingSet bindings,
076: boolean includeInferred) throws SailException {
077: return wrappedCon.evaluate(tupleExpr, dataset, bindings,
078: includeInferred);
079: }
080:
081: public CloseableIteration<? extends Resource, SailException> getContextIDs()
082: throws SailException {
083: return wrappedCon.getContextIDs();
084: }
085:
086: public CloseableIteration<? extends Statement, SailException> getStatements(
087: Resource subj, URI pred, Value obj,
088: boolean includeInferred, Resource... contexts)
089: throws SailException {
090: return wrappedCon.getStatements(subj, pred, obj,
091: includeInferred, contexts);
092: }
093:
094: public long size(Resource... contexts) throws SailException {
095: return wrappedCon.size(contexts);
096: }
097:
098: public long size(Resource context) throws SailException {
099: return wrappedCon.size(context);
100: }
101:
102: public void commit() throws SailException {
103: wrappedCon.commit();
104: }
105:
106: public void rollback() throws SailException {
107: wrappedCon.rollback();
108: }
109:
110: public void addStatement(Resource subj, URI pred, Value obj,
111: Resource... contexts) throws SailException {
112: wrappedCon.addStatement(subj, pred, obj, contexts);
113: }
114:
115: public void removeStatements(Resource subj, URI pred, Value obj,
116: Resource... contexts) throws SailException {
117: wrappedCon.removeStatements(subj, pred, obj, contexts);
118: }
119:
120: public void clear(Resource... contexts) throws SailException {
121: wrappedCon.clear(contexts);
122: }
123:
124: public CloseableIteration<? extends Namespace, SailException> getNamespaces()
125: throws SailException {
126: return wrappedCon.getNamespaces();
127: }
128:
129: public String getNamespace(String prefix) throws SailException {
130: return wrappedCon.getNamespace(prefix);
131: }
132:
133: public void setNamespace(String prefix, String name)
134: throws SailException {
135: wrappedCon.setNamespace(prefix, name);
136: }
137:
138: public void removeNamespace(String prefix) throws SailException {
139: wrappedCon.removeNamespace(prefix);
140: }
141:
142: public void clearNamespaces() throws SailException {
143: wrappedCon.clearNamespaces();
144: }
145:
146: public void addConnectionListener(SailConnectionListener listener) {
147: wrappedCon.addConnectionListener(listener);
148: }
149:
150: public void removeConnectionListener(SailConnectionListener listener) {
151: wrappedCon.addConnectionListener(listener);
152: }
153: }
|