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.openrdf.sail.inferencer.fc;
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 ForwardChainingRDFSInferencer extends SailWrapper {
21:
22: /*--------------*
23: * Constructors *
24: *--------------*/
25:
26: public ForwardChainingRDFSInferencer() {
27: super ();
28: }
29:
30: public ForwardChainingRDFSInferencer(Sail baseSail) {
31: super (baseSail);
32: }
33:
34: /*---------*
35: * Methods *
36: *---------*/
37:
38: @Override
39: public ForwardChainingRDFSInferencerConnection getConnection()
40: throws SailException {
41: try {
42: InferencerConnection con = (InferencerConnection) super
43: .getConnection();
44: return new ForwardChainingRDFSInferencerConnection(con);
45: } catch (ClassCastException e) {
46: throw new SailException(e.getMessage(), e);
47: }
48: }
49:
50: /**
51: * Adds axiom statements to the underlying Sail.
52: */
53: @Override
54: public void initialize() throws SailException {
55: super .initialize();
56:
57: ForwardChainingRDFSInferencerConnection con = getConnection();
58: try {
59: con.addAxiomStatements();
60: con.commit();
61: } finally {
62: con.close();
63: }
64: }
65: }
|