KickJava   Java API By Example, From Geeks To Geeks.

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


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: DIGQueryRoleHierarchyTranslator.java,v $
10  * Revision $Revision: 1.4 $
11  * Release status $State: Exp $
12  *
13  * Last modified on $Date: 2005/02/21 12:16:24 $
14  * by $Author: andy_seaborne $
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.Iterator JavaDoc;
28
29
30 import com.hp.hpl.jena.graph.*;
31 import com.hp.hpl.jena.graph.Triple;
32 import com.hp.hpl.jena.reasoner.TriplePattern;
33 import com.hp.hpl.jena.reasoner.rulesys.Node_RuleVariable;
34 import com.hp.hpl.jena.util.iterator.*;
35 import com.hp.hpl.jena.vocabulary.RDF;
36
37
38
39 /**
40  * <p>
41  * Translator that generates DIG queries in response to find queries that search the entire class
42  * hierarchy:
43  * <pre>
44  * * rdf:subClassOf *
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: DIGQueryRoleHierarchyTranslator.java,v 1.4 2005/02/21 12:16:24 andy_seaborne Exp $)
51  */

52 public class DIGQueryRoleHierarchyTranslator
53     extends DIGIteratedQueryTranslator
54 {
55
56     // Constants
57
//////////////////////////////////
58

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

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

65     
66     
67     // Constructors
68
//////////////////////////////////
69

70     /**
71      * <p>Construct a translator for the DIG class hierarchy queries.</p>
72      * @param predicate The predicate URI to trigger on
73      */

74     public DIGQueryRoleHierarchyTranslator( String JavaDoc predicate ) {
75         super( ALL, predicate, ALL );
76     }
77
78
79     // External signature methods
80
//////////////////////////////////
81

82     /**
83      * <p>To query the entire role hierarchy, we need to know every super-class of every class.</p>
84      * @param pattern The incoming pattern
85      * @param da The current DIG adapter
86      */

87     protected Iterator JavaDoc expandQuery( TriplePattern pattern, DIGAdapter da ) {
88         final Node pred = pattern.getPredicate();
89
90         // find all concepts, and use them to replace the lhs nodes in the pattern
91
return new DIGQueryAllRolesTranslator( null, null )
92                .find( new TriplePattern( null, RDF.type.asNode(), null ), da )
93                .mapWith( new Map1() {
94                    public Object JavaDoc map1( Object JavaDoc x ) {
95                        Triple triple = (Triple) x;
96                        return new TriplePattern( triple.getSubject(), pred, Node_RuleVariable.WILD );
97                    }
98                } );
99     }
100
101
102
103     // Internal implementation methods
104
//////////////////////////////////
105

106     //==============================================================================
107
// Inner class definitions
108
//==============================================================================
109

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

139
Popular Tags