KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > reasoner > dig > DIGQueryIsRoleTranslator


1 /*****************************************************************************
2  * Source code information
3  * -----------------------
4  * Original author Ian Dickinson, HP Labs Bristol
5  * Author email Ian.Dickinson@hp.com
6  * Package Jena 2
7  * Web http://sourceforge.net/projects/jena/
8  * Created July 19th 2003
9  * Filename $RCSfile: DIGQueryIsRoleTranslator.java,v $
10  * Revision $Revision: 1.5 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/03/16 18:52:27 $
14  * by $Author: ian_dickinson $
15  *
16  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
17  * [See end of file]
18  * ****************************************************************************/

19
20 // Package
21
///////////////
22
package com.hp.hpl.jena.reasoner.dig;
23
24
25 // Imports
26
///////////////
27
import java.util.*;
28
29 import org.w3c.dom.Document JavaDoc;
30
31 import com.hp.hpl.jena.graph.*;
32 import com.hp.hpl.jena.rdf.model.Model;
33 import com.hp.hpl.jena.reasoner.TriplePattern;
34 import com.hp.hpl.jena.util.iterator.*;
35 import com.hp.hpl.jena.vocabulary.RDF;
36
37
38 /**
39  * <p>
40  * Translator that generates a DIG query to test whether a ground name is an role atom
41  * <pre>
42  * x rdf:type owl:ObjectProperty
43  * </pre>
44  * or similar.
45  * </p>
46  *
47  * @author Ian Dickinson, HP Labs (<a HREF="mailto:Ian.Dickinson@hp.com">email</a>)
48  * @version Release @release@ ($Id: DIGQueryIsRoleTranslator.java,v 1.5 2005/03/16 18:52:27 ian_dickinson Exp $)
49  */

50 public class DIGQueryIsRoleTranslator
51     extends DIGQueryTranslator
52 {
53
54     // Constants
55
//////////////////////////////////
56

57     // Static variables
58
//////////////////////////////////
59

60     // Instance variables
61
//////////////////////////////////
62

63     // Constructors
64
//////////////////////////////////
65

66     /**
67      * <p>Construct a translator for the DIG for a role name.</p>
68      */

69     public DIGQueryIsRoleTranslator() {
70         super( null, RDF.type.getURI(), null );
71     }
72     
73
74     // External signature methods
75
//////////////////////////////////
76

77
78     /**
79      * <p>Since known concept names are cached by the adapter, we can just look up the
80      * current set and map directly to triples</p>
81      * @param pattern The pattern to translate to a DIG query
82      * @param da The DIG adapter through which we communicate with a DIG reasoner
83      */

84     public ExtendedIterator find( TriplePattern pattern, DIGAdapter da ) {
85         List result = new ArrayList();
86         if (da.isRole( pattern.getSubject(), null )) {
87             result.add( pattern.asTriple() );
88         }
89         
90         return WrappedIterator.create( result.iterator() );
91     }
92     
93     
94     /** For this translation, we ignore premises */
95     public ExtendedIterator find( TriplePattern pattern, DIGAdapter da, Model premises ) {
96         return find( pattern, da );
97     }
98     
99     
100     public Document JavaDoc translatePattern( TriplePattern pattern, DIGAdapter da ) {
101         // not used
102
return null;
103     }
104
105
106     public Document JavaDoc translatePattern( TriplePattern pattern, DIGAdapter da, Model premises ) {
107         // not used
108
return null;
109     }
110
111     public ExtendedIterator translateResponseHook( Document JavaDoc response, TriplePattern query, DIGAdapter da ) {
112         // not used
113
return null;
114     }
115
116     /**
117      * <p>Additional test on the object of the incoming find pattern.</p>
118      * @param object The object resource from the incoming pattern
119      * @param da The current dig adapter
120      * @param premises A model that conveys additional information about the premises
121      * of the query, which might assist the check to suceed or fail. By default it
122      * is ignored.
123      * @return True if this object matches the trigger condition expressed by this translator instance
124      */

125     public boolean checkObject( Node object, DIGAdapter da, Model premises ) {
126         return da.getOntLanguage().OBJECT_PROPERTY().getNode().equals( object );
127     }
128     
129
130     public boolean checkSubject( Node subject, DIGAdapter da, Model premises ) {
131         return subject instanceof Node_Concrete;
132     }
133     
134
135     // Internal implementation methods
136
//////////////////////////////////
137

138     //==============================================================================
139
// Inner class definitions
140
//==============================================================================
141

142 }
143
144
145 /*
146  * (c) Copyright 2001-2004, 2005 Hewlett-Packard Development Company, LP
147  * All rights reserved.
148  *
149  * Redistribution and use in source and binary forms, with or without
150  * modification, are permitted provided that the following conditions
151  * are met:
152  * 1. Redistributions of source code must retain the above copyright
153  * notice, this list of conditions and the following disclaimer.
154  * 2. Redistributions in binary form must reproduce the above copyright
155  * notice, this list of conditions and the following disclaimer in the
156  * documentation and/or other materials provided with the distribution.
157  * 3. The name of the author may not be used to endorse or promote products
158  * derived from this software without specific prior written permission.
159  *
160  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
162  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
163  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
164  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
165  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
166  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
167  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
168  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
169  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
170  */

171
Popular Tags