KickJava   Java API By Example, From Geeks To Geeks.

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


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

10 package com.hp.hpl.jena.reasoner.rulesys;
11
12 import java.util.*;
13
14 import com.hp.hpl.jena.graph.Capabilities;
15 import com.hp.hpl.jena.reasoner.BaseInfGraph;
16 import com.hp.hpl.jena.reasoner.ReasonerFactory;
17
18 /**
19  * A pure forward chaining implementation of the RDFS closure rules
20  * based upon the basic forward rule interpreter. The normal mixed
21  * forward/backward implementation is generally preferred but this has
22  * two possible uses. First, it is a test and demonstration of the forward
23  * chainer. Second, if you want all the RDFS entailments for an entire
24  * dataset the forward chainer will be more efficient.
25  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
26  * @version $Revision: 1.6 $ on $Date: 2005/02/21 12:17:04 $ */

27
28 public class RDFSForwardRuleReasoner extends GenericRuleReasoner {
29     /** The location of the OWL rule definitions on the class path */
30     public static final String JavaDoc RULE_FILE = "etc/rdfs.rules";
31 // public static final String RULE_FILE = "etc/rdfs-noresource.rules";
32

33     /** The parsed rules */
34     protected static List ruleSet;
35     
36     /**
37      * Constructor
38      */

39     public RDFSForwardRuleReasoner(ReasonerFactory parent) {
40         super(loadRules(), parent);
41 // setMode(FORWARD_RETE);
42
setMode(FORWARD);
43     }
44     
45     /**
46      * Return the RDFS rule set, loading it in if necessary
47      */

48     public static List loadRules() {
49         if (ruleSet == null) ruleSet = loadRules( RULE_FILE );
50         return ruleSet;
51     }
52
53     /**
54      * Return the Jena Graph Capabilties that the inference graphs generated
55      * by this reasoner are expected to conform to.
56      */

57     public Capabilities getGraphCapabilities() {
58         if (capabilities == null) {
59             capabilities = new BaseInfGraph.InfFindSafeCapabilities();
60         }
61         return capabilities;
62     }
63         
64 }
65
66 /*
67     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
68     All rights reserved.
69
70     Redistribution and use in source and binary forms, with or without
71     modification, are permitted provided that the following conditions
72     are met:
73
74     1. Redistributions of source code must retain the above copyright
75        notice, this list of conditions and the following disclaimer.
76
77     2. Redistributions in binary form must reproduce the above copyright
78        notice, this list of conditions and the following disclaimer in the
79        documentation and/or other materials provided with the distribution.
80
81     3. The name of the author may not be used to endorse or promote products
82        derived from this software without specific prior written permission.
83
84     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
85     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
86     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
87     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
88     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
89     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
90     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
91     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
92     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
93     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
94 */

95
Popular Tags