KickJava   Java API By Example, From Geeks To Geeks.

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


1 /******************************************************************
2  * File: OWLMicroReasonerFactory.java
3  * Created by: Dave Reynolds
4  * Created on: 21-Mar-2004
5  *
6  * (c) Copyright 2004, 2005 Hewlett-Packard Development Company, LP, all rights reserved.
7  * [See end of file]
8  * $Id: OWLMicroReasonerFactory.java,v 1.7 2005/04/11 11:17:06 der Exp $
9  *****************************************************************/

10 package com.hp.hpl.jena.reasoner.rulesys;
11
12
13 import com.hp.hpl.jena.reasoner.*;
14 import com.hp.hpl.jena.reasoner.rulesys.Util;
15 import com.hp.hpl.jena.reasoner.transitiveReasoner.TransitiveReasoner;
16 import com.hp.hpl.jena.rdf.model.*;
17 import com.hp.hpl.jena.vocabulary.*;
18
19 /**
20  * Reasoner factory for the OWL micro configuration.
21  * This only supports:
22  * <ul>
23  * <li>RDFS entailments</li>
24  * <li>basic OWL axioms like ObjectProperty subClassOf Property</li>
25  * <li>intersectionOf, equivalentClass and forward implication of unionOf sufficient for traversal
26  * of explicit class hierachies<.li>
27  * <li>Property axioms (inversOf, SymmetricProperty, TransitiveProperty, equivalentProperty)</li>
28  * </ul>
29  * There is some experimental support for the cheaper class restriction handlingly which
30  * should not be relied on at this point.
31  *
32  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
33  * @version $Revision: 1.7 $ on $Date: 2005/04/11 11:17:06 $
34  */

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

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

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

78     public Model getCapabilities() {
79         if (capabilities == null) {
80             capabilities = ModelFactory.createDefaultModel();
81             Resource base = capabilities.createResource(getURI());
82             base.addProperty(ReasonerVocabulary.nameP, "OWL Mini Reasoner")
83                 .addProperty(ReasonerVocabulary.descriptionP, "Experimental mini OWL reasoner.\n"
84                                             + "Can separate tbox and abox data if desired to reuse tbox caching or mix them.")
85                 .addProperty(ReasonerVocabulary.supportsP, RDFS.subClassOf)
86                 .addProperty(ReasonerVocabulary.supportsP, RDFS.subPropertyOf)
87                 .addProperty(ReasonerVocabulary.supportsP, RDFS.member)
88                 .addProperty(ReasonerVocabulary.supportsP, RDFS.range)
89                 .addProperty(ReasonerVocabulary.supportsP, RDFS.domain)
90                 .addProperty(ReasonerVocabulary.supportsP, TransitiveReasoner.directSubClassOf)
91                 .addProperty(ReasonerVocabulary.supportsP, TransitiveReasoner.directSubPropertyOf)
92                 // TODO - add OWL elements supported
93
.addProperty(ReasonerVocabulary.supportsP, OWL.ObjectProperty )
94                 .addProperty(ReasonerVocabulary.supportsP, OWL.DatatypeProperty)
95                 .addProperty(ReasonerVocabulary.supportsP, OWL.FunctionalProperty )
96                 .addProperty(ReasonerVocabulary.supportsP, OWL.SymmetricProperty )
97                 .addProperty(ReasonerVocabulary.supportsP, OWL.TransitiveProperty )
98                 .addProperty(ReasonerVocabulary.supportsP, OWL.InverseFunctionalProperty )
99
100                 .addProperty(ReasonerVocabulary.supportsP, OWL.hasValue )
101                 .addProperty(ReasonerVocabulary.supportsP, OWL.intersectionOf )
102                 .addProperty(ReasonerVocabulary.supportsP, OWL.unionOf ) // Only partial
103

104                 .addProperty(ReasonerVocabulary.versionP, "0.1");
105         }
106         return capabilities;
107     }
108     
109     /**
110      * Return the URI labelling this type of reasoner
111      */

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