KickJava   Java API By Example, From Geeks To Geeks.

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


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: DIGQueryRoleParentsTranslator.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 org.w3c.dom.Element JavaDoc;
28 import org.w3c.dom.Document JavaDoc;
29
30 import com.hp.hpl.jena.reasoner.TriplePattern;
31
32
33
34 /**
35  * <p>
36  * Translator that generates DIG parents/childre queries in response to a find queries:
37  * <pre>
38  * :X direct-subClassOf *
39  * * direct-subClassOf :X
40  * </pre>
41  * or similar.
42  * </p>
43  *
44  * @author Ian Dickinson, HP Labs (<a HREF="mailto:Ian.Dickinson@hp.com">email</a>)
45  * @version Release @release@ ($Id: DIGQueryRoleParentsTranslator.java,v 1.4 2005/02/21 12:16:24 andy_seaborne Exp $)
46  */

47 public class DIGQueryRoleParentsTranslator
48     extends DIGQueryRoleAncestorsTranslator
49 {
50
51     // Constants
52
//////////////////////////////////
53

54     // Static variables
55
//////////////////////////////////
56

57     // Instance variables
58
//////////////////////////////////
59

60     
61     // Constructors
62
//////////////////////////////////
63

64     /**
65      * <p>Construct a translator for the DIG query 'rparents'.</p>
66      * @param predicate The predicate URI to trigger on
67      * @param parents If true, we are searching for parents of the role; if false, the children
68      */

69     public DIGQueryRoleParentsTranslator( String JavaDoc predicate, boolean parents ) {
70         super( predicate, parents );
71     }
72     
73
74     // External signature methods
75
//////////////////////////////////
76

77
78     /**
79      * <p>Answer a query that will generate the direct class hierarchy (one level up or down) for a node</p>
80      */

81     public Document JavaDoc translatePattern( TriplePattern pattern, DIGAdapter da ) {
82         DIGConnection dc = da.getConnection();
83         Document JavaDoc query = dc.createDigVerb( DIGProfile.ASKS, da.getProfile() );
84         
85         if (m_ancestors) {
86             Element JavaDoc parents = da.createQueryElement( query, DIGProfile.RPARENTS );
87             da.addClassDescription( parents, pattern.getSubject() );
88         }
89         else {
90             Element JavaDoc descendants = da.createQueryElement( query, DIGProfile.RCHILDREN );
91             da.addClassDescription( descendants, pattern.getObject() );
92         }
93         
94         return query;
95     }
96
97
98
99     // Internal implementation methods
100
//////////////////////////////////
101

102     //==============================================================================
103
// Inner class definitions
104
//==============================================================================
105

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

135
Popular Tags