01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.semweb4j.sesame;
07:
08: import org.openrdf.sail.Sail;
09: import org.openrdf.sail.SailException;
10: import org.openrdf.sail.helpers.SailWrapper;
11: import org.openrdf.sail.inferencer.InferencerConnection;
12:
13: /**
14: * Forward-chaining RDF Schema inferencer, using the rules from the <a
15: * href="http://www.w3.org/TR/2004/REC-rdf-mt-20040210/">RDF Semantics
16: * Recommendation (10 February 2004)</a>. This inferencer can be used to add
17: * RDF Schema semantics to any Sail that returns {@link InferencerConnection}s
18: * from their {@link Sail#getConnection()} method.
19: */
20: public class ForwardChainingRDFSPlusInverseInferencer extends
21: SailWrapper {
22:
23: /*--------------*
24: * Constructors *
25: *--------------*/
26:
27: public ForwardChainingRDFSPlusInverseInferencer() {
28: super ();
29: }
30:
31: public ForwardChainingRDFSPlusInverseInferencer(Sail baseSail) {
32: super (baseSail);
33: }
34:
35: /*---------*
36: * Methods *
37: *---------*/
38:
39: @Override
40: public ForwardChainingRDFSPlusInverseInferencerConnection getConnection()
41: throws SailException {
42: try {
43: InferencerConnection con = (InferencerConnection) super
44: .getConnection();
45: return new ForwardChainingRDFSPlusInverseInferencerConnection(
46: con);
47: } catch (ClassCastException e) {
48: throw new SailException(e.getMessage(), e);
49: }
50: }
51:
52: /**
53: * Adds axiom statements to the underlying Sail.
54: */
55: @Override
56: public void initialize() throws SailException {
57: super .initialize();
58:
59: ForwardChainingRDFSPlusInverseInferencerConnection con = getConnection();
60: try {
61: con.addAxiomStatements();
62: con.commit();
63: } finally {
64: con.close();
65: }
66: }
67: }
|