KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > reasoner > rdfsReasoner1 > RDFSReasonerFactory


1 /******************************************************************
2  * File: RDFSReasonerFactory.java
3  * Created by: Dave Reynolds
4  * Created on: 21-Jan-03
5  *
6  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
7  * [See end of file]
8  * $Id: RDFSReasonerFactory.java,v 1.16 2005/02/21 12:16:51 andy_seaborne Exp $
9  *****************************************************************/

10 package com.hp.hpl.jena.reasoner.rdfsReasoner1;
11
12 import com.hp.hpl.jena.reasoner.*;
13 import com.hp.hpl.jena.reasoner.transitiveReasoner.TransitiveReasoner;
14 import com.hp.hpl.jena.rdf.model.*;
15 import com.hp.hpl.jena.rdf.model.impl.PropertyImpl;
16 import com.hp.hpl.jena.vocabulary.*;
17
18 /**
19  * Factory class for creating blank instances of the RDFS reasoner.
20  *
21  * @deprecated Obsoleted at jena2p4, replaced by
22  * {@link com.hp.hpl.jena.reasoner.rulesys.RDFSRuleReasonerFactory}.
23  *
24  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
25  * @version $Revision: 1.16 $ on $Date: 2005/02/21 12:16:51 $
26  */

27 public class RDFSReasonerFactory implements ReasonerFactory {
28     
29     /** Single global instance of this factory */
30     private static ReasonerFactory theInstance = new RDFSReasonerFactory();
31     
32     /** Static URI for this reasoner type */
33     public static final String JavaDoc URI = "http://jena.hpl.hp.com/2003/RDFSReasoner1";
34     
35     /** Cache of the capabilities description */
36     protected Model capabilities;
37     
38     /** Property used to configure the scan behaviour of the reasoner.
39      * Set to "true" to enable scanning of triples looking for rdf:_1 assertions. */

40     public static final Property scanProperties = new PropertyImpl(URI+"#", "scanProperties");
41     
42     /**
43      * Return the single global instance of this factory
44      */

45     public static ReasonerFactory theInstance() {
46         return theInstance;
47     }
48     
49     /**
50      * Constructor method that builds an instance of the associated Reasoner
51      * @param configuration a set of arbitrary configuration information to be
52      * passed the reasoner, encoded as RDF properties of a base configuration resource,
53      * can be null in no custom configuration is required.
54      */

55     public Reasoner create(Resource configuration) {
56         return new RDFSReasoner(configuration);
57     }
58    
59     /**
60      * Return a description of the capabilities of this reasoner encoded in
61      * RDF. This method is normally called by the ReasonerRegistry which caches
62      * the resulting information so dynamically creating here is not really an overhead.
63      */

64     public Model getCapabilities() {
65         if (capabilities == null) {
66             capabilities = ModelFactory.createDefaultModel();
67             Resource base = capabilities.createResource(getURI());
68             base.addProperty(ReasonerVocabulary.nameP, "RDFS Reasoner 1")
69                 .addProperty(ReasonerVocabulary.descriptionP, "Complete RDFS implementation supporting metalevel statements.\n"
70                                             + "Eager caching of schema information, back chaining for most entailments\n"
71                                             + "Can separate tbox and abox data if desired to reuse tbox caching or mix them.")
72                 .addProperty(ReasonerVocabulary.configurationP, scanProperties)
73                 .addProperty(ReasonerVocabulary.supportsP, RDFS.subClassOf)
74                 .addProperty(ReasonerVocabulary.supportsP, RDFS.subPropertyOf)
75                 .addProperty(ReasonerVocabulary.supportsP, RDFS.member)
76                 .addProperty(ReasonerVocabulary.supportsP, RDFS.range)
77                 .addProperty(ReasonerVocabulary.supportsP, RDFS.domain)
78                 .addProperty(ReasonerVocabulary.supportsP, TransitiveReasoner.directSubClassOf)
79                 .addProperty(ReasonerVocabulary.supportsP, TransitiveReasoner.directSubPropertyOf)
80                 .addProperty(ReasonerVocabulary.versionP, "0.1");
81         }
82         return capabilities;
83     }
84     
85     /**
86      * Return the URI labelling this type of reasoner
87      */

88     public String JavaDoc getURI() {
89         return URI;
90     }
91     
92     /**
93      * Temporary testing hack
94      */

95     public static void main(String JavaDoc[] args) {
96         Resource rdfsDescr = ReasonerRegistry.theRegistry().getDescription(URI);
97         System.out.println("Reasoner: " + rdfsDescr);
98         for (StmtIterator i = rdfsDescr.listProperties(); i.hasNext(); ) {
99             Statement s = i.nextStatement();
100             System.out.println(s.getPredicate().getLocalName() + " = " + s.getObject());
101         }
102     }
103 }
104
105 /*
106     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
107     All rights reserved.
108
109     Redistribution and use in source and binary forms, with or without
110     modification, are permitted provided that the following conditions
111     are met:
112
113     1. Redistributions of source code must retain the above copyright
114        notice, this list of conditions and the following disclaimer.
115
116     2. Redistributions in binary form must reproduce the above copyright
117        notice, this list of conditions and the following disclaimer in the
118        documentation and/or other materials provided with the distribution.
119
120     3. The name of the author may not be used to endorse or promote products
121        derived from this software without specific prior written permission.
122
123     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
124     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
125     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
126     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
127     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
128     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
129     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
130     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
131     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
132     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
133 */

134
135
Popular Tags