KickJava   Java API By Example, From Geeks To Geeks.

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


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: DIGQueryIsConceptTranslator.java,v $
10  * Revision $Revision: 1.4 $
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.Node;
32 import com.hp.hpl.jena.graph.Node_Concrete;
33 import com.hp.hpl.jena.rdf.model.Model;
34 import com.hp.hpl.jena.reasoner.TriplePattern;
35 import com.hp.hpl.jena.util.iterator.*;
36 import com.hp.hpl.jena.util.iterator.ExtendedIterator;
37 import com.hp.hpl.jena.vocabulary.RDF;
38
39
40 /**
41  * <p>
42  * Translator that generates a DIG query to test whether a ground name is a class atom
43  * <pre>
44  * x rdf:type owl:Class
45  * </pre>
46  * or similar.
47  * </p>
48  *
49  * @author Ian Dickinson, HP Labs (<a HREF="mailto:Ian.Dickinson@hp.com">email</a>)
50  * @version Release @release@ ($Id: DIGQueryIsConceptTranslator.java,v 1.4 2005/03/16 18:52:27 ian_dickinson Exp $)
51  */

52 public class DIGQueryIsConceptTranslator
53     extends DIGQueryTranslator
54 {
55
56     // Constants
57
//////////////////////////////////
58

59     // Static variables
60
//////////////////////////////////
61

62     // Instance variables
63
//////////////////////////////////
64

65     // Constructors
66
//////////////////////////////////
67

68     /**
69      * <p>Construct a translator for the DIG for a concept name.</p>
70      */

71     public DIGQueryIsConceptTranslator() {
72         super( null, RDF.type.getURI(), null );
73     }
74     
75
76     // External signature methods
77
//////////////////////////////////
78

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

86     public ExtendedIterator find( TriplePattern pattern, DIGAdapter da ) {
87         List result = new ArrayList();
88         if (da.isConcept( pattern.getSubject(), null )) {
89             result.add( pattern.asTriple() );
90         }
91         
92         return WrappedIterator.create( result.iterator() );
93     }
94     
95     /** For this translation, we ignore premises */
96     public ExtendedIterator find( TriplePattern pattern, DIGAdapter da, Model premises ) {
97         return find( pattern, da );
98     }
99     
100     
101     public Document JavaDoc translatePattern( TriplePattern pattern, DIGAdapter da ) {
102         // not used
103
return null;
104     }
105
106
107     public Document JavaDoc translatePattern( TriplePattern pattern, DIGAdapter da, Model premises ) {
108         // not used
109
return null;
110     }
111
112     public ExtendedIterator translateResponseHook( Document JavaDoc response, TriplePattern query, DIGAdapter da ) {
113         // not used
114
return null;
115     }
116
117     public boolean checkObject( Node object, DIGAdapter da, Model premises ) {
118         return da.getOntLanguage().CLASS().getNode().equals( object );
119     }
120     
121
122     public boolean checkSubject( Node subject, DIGAdapter da, Model premises ) {
123         return subject instanceof Node_Concrete;
124     }
125     
126
127     // Internal implementation methods
128
//////////////////////////////////
129

130     //==============================================================================
131
// Inner class definitions
132
//==============================================================================
133

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

163
Popular Tags