KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > reasoner > rulesys > OWLFBRuleReasonerFactory


1 /******************************************************************
2  * File: OWLBRuleReasonerFactory.java
3  * Created by: Dave Reynolds
4  * Created on: 12-May-2003
5  *
6  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
7  * [See end of file]
8  * $Id: OWLFBRuleReasonerFactory.java,v 1.14 2005/04/11 11:17:06 der Exp $
9  *****************************************************************/

10 package com.hp.hpl.jena.reasoner.rulesys;
11
12 import com.hp.hpl.jena.reasoner.*;
13 import com.hp.hpl.jena.rdf.model.*;
14 import com.hp.hpl.jena.vocabulary.*;
15
16 /**
17  * Factory class for creating blank instances of the OWL Reasoner.
18  * <p>
19  * The reasoner can be configured using three properties (set as
20  * properties of the base reasonder URI in a configuration model). These are:
21  * <ul>
22  * <li><b>derivationLogging</b> - if set to true this causes all derivations to
23  * be recorded in an internal data structure for replay through the {@link com.hp.hpl.jena.reasoner.InfGraph#getDerivation getDerivation}
24  * method. </li>
25  * <li><b>traceOn</b> - if set to true this causes all rule firings and deduced triples to be
26  * written out to the Log at INFO level.</li>
27  * <li><b>ruleThreshold</b> - which limits the number of rules that can be fired on a single
28  * data processing stage to the given number (useful to limit infinite runaways). </li>
29  * </ul>
30  *
31  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
32  * @version $Revision: 1.14 $ on $Date: 2005/04/11 11:17:06 $
33  */

34 public class OWLFBRuleReasonerFactory implements ReasonerFactory {
35     
36     /** Single global instance of this factory */
37     private static ReasonerFactory theInstance = new OWLFBRuleReasonerFactory();
38     
39     /** Static URI for this reasoner type */
40     public static final String JavaDoc URI = "http://jena.hpl.hp.com/2003/OWLFBRuleReasoner";
41     
42     /** Cache of the capabilities description */
43     protected Model capabilities;
44     
45     /**
46      * Return the single global instance of this factory
47      */

48     public static ReasonerFactory theInstance() {
49         return theInstance;
50     }
51     
52     /**
53      * Constructor method that builds an instance of the associated Reasoner
54      * @param configuration a set of arbitrary configuration information to be
55      * passed the reasoner encoded within an RDF graph
56      */

57     public Reasoner create(Resource configuration) {
58         OWLFBRuleReasoner reasoner = new OWLFBRuleReasoner(this);
59         if (configuration != null) {
60             Boolean JavaDoc doLog = Util.checkBinaryPredicate(ReasonerVocabulary.PROPderivationLogging, configuration);
61             if (doLog != null) {
62                 reasoner.setDerivationLogging(doLog.booleanValue());
63             }
64             Boolean JavaDoc doTrace = Util.checkBinaryPredicate(ReasonerVocabulary.PROPtraceOn, configuration);
65             if (doTrace != null) {
66                 reasoner.setTraceOn(doTrace.booleanValue());
67             }
68         }
69         return reasoner;
70     }
71    
72     /**
73      * Return a description of the capabilities of this reasoner encoded in
74      * RDF. This method is normally called by the ReasonerRegistry which caches
75      * the resulting information so dynamically creating here is not really an overhead.
76      */

77     public Model getCapabilities() {
78         if (capabilities == null) {
79             capabilities = ModelFactory.createDefaultModel();
80             Resource base = capabilities.createResource(getURI());
81             base.addProperty(ReasonerVocabulary.nameP, "OWL BRule Reasoner")
82                 .addProperty(ReasonerVocabulary.descriptionP, "Experimental OWL reasoner.\n"
83                                             + "Can separate tbox and abox data if desired to reuse tbox caching or mix them.")
84                 .addProperty(ReasonerVocabulary.supportsP, RDFS.subClassOf)
85                 .addProperty(ReasonerVocabulary.supportsP, RDFS.subPropertyOf)
86                 .addProperty(ReasonerVocabulary.supportsP, RDFS.member)
87                 .addProperty(ReasonerVocabulary.supportsP, RDFS.range)
88                 .addProperty(ReasonerVocabulary.supportsP, RDFS.domain)
89                 // TODO - add OWL elements supported
90
.addProperty(ReasonerVocabulary.supportsP, ReasonerVocabulary.individualAsThingP )
91                 .addProperty(ReasonerVocabulary.supportsP, OWL.ObjectProperty )
92                 .addProperty(ReasonerVocabulary.supportsP, OWL.DatatypeProperty)
93                 .addProperty(ReasonerVocabulary.supportsP, OWL.FunctionalProperty )
94                 .addProperty(ReasonerVocabulary.supportsP, OWL.SymmetricProperty )
95                 .addProperty(ReasonerVocabulary.supportsP, OWL.TransitiveProperty )
96                 .addProperty(ReasonerVocabulary.supportsP, OWL.InverseFunctionalProperty )
97
98                 .addProperty(ReasonerVocabulary.supportsP, OWL.hasValue )
99                 .addProperty(ReasonerVocabulary.supportsP, OWL.intersectionOf )
100                 .addProperty(ReasonerVocabulary.supportsP, OWL.unionOf ) // Only partial
101
.addProperty(ReasonerVocabulary.supportsP, OWL.minCardinality ) // Only partial
102
.addProperty(ReasonerVocabulary.supportsP, OWL.maxCardinality ) // Only partial
103
.addProperty(ReasonerVocabulary.supportsP, OWL.cardinality ) // Only partial
104
.addProperty(ReasonerVocabulary.supportsP, OWL.someValuesFrom) // Only partial
105
.addProperty(ReasonerVocabulary.supportsP, OWL.allValuesFrom ) // Only partial
106
.addProperty(ReasonerVocabulary.supportsP, OWL.sameAs )
107                 .addProperty(ReasonerVocabulary.supportsP, OWL.differentFrom )
108                 .addProperty(ReasonerVocabulary.supportsP, OWL.disjointWith )
109                 
110                 .addProperty(ReasonerVocabulary.versionP, "0.1");
111         }
112         return capabilities;
113     }
114     
115     /**
116      * Return the URI labelling this type of reasoner
117      */

118     public String JavaDoc getURI() {
119         return URI;
120     }
121     
122 }
123
124 /*
125     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
126     All rights reserved.
127
128     Redistribution and use in source and binary forms, with or without
129     modification, are permitted provided that the following conditions
130     are met:
131
132     1. Redistributions of source code must retain the above copyright
133        notice, this list of conditions and the following disclaimer.
134
135     2. Redistributions in binary form must reproduce the above copyright
136        notice, this list of conditions and the following disclaimer in the
137        documentation and/or other materials provided with the distribution.
138
139     3. The name of the author may not be used to endorse or promote products
140        derived from this software without specific prior written permission.
141
142     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
143     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
144     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
145     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
146     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
147     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
148     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
149     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
150     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
151     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
152 */
Popular Tags