KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > joseki > QuerySPO


1 /*
2  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
3  * [See end of file]
4  */

5
6
7 /** Client acess to the SPO query language.
8  * <p>
9  * An SPO request takes three arguments:
10  * <pre>
11  * subject URI,m predciate URI and object (URI or string)
12  * </pre>
13  * where not specifying a value means wildcard. See the Jena Model.listStatements(S,P,O)
14  * operation.
15  *
16  * @author Andy Seaborne
17  * @version $Id: QuerySPO.java,v 1.5 2004/04/30 14:13:13 andy_seaborne Exp $
18  */

19  
20 package com.hp.hpl.jena.joseki;
21
22 import org.apache.commons.logging.* ;
23 import com.hp.hpl.jena.rdf.model.* ;
24
25 public class QuerySPO extends HttpQuery
26 {
27     static Log logger = LogFactory.getLog(QuerySPO.class.getName()) ;
28     
29     String JavaDoc subject = null ;
30     String JavaDoc predicate = null ;
31     String JavaDoc object = null ;
32     String JavaDoc value = null ;
33     boolean closure = false ;
34     
35     /** Create a request going to the named model.
36      *
37      * @param target
38      */

39     
40     public QuerySPO(String JavaDoc target)
41     {
42         super(target, "Triples") ;
43     }
44
45     /** Create a request going to the named model, with specified
46      * subject, predicate and string value
47      *
48      * @param target
49      * @param r
50      * @param p
51      * @param lit
52      */

53     
54     public QuerySPO(String JavaDoc target, Resource r, Property p, Literal lit)
55     {
56         super(target, "Triples") ;
57         if ( r != null )
58             setSubject(r.getURI()) ;
59         if ( p != null )
60             setPredicate(p.getURI()) ;
61         if ( lit != null )
62             setValue(lit.getLexicalForm()) ;
63     }
64
65     /** Create a request going to the named model, with specified
66      * subject, predicate and object resource.
67      *
68      * @param target
69      * @param r
70      * @param p
71      * @param obj
72      */

73
74     public QuerySPO(String JavaDoc target, Resource r, Property p, Resource obj)
75     {
76         super(target, "Triples") ;
77         if ( r != null )
78             setSubject(r.getURI()) ;
79         if ( p != null )
80             setPredicate(p.getURI()) ;
81         if ( obj != null )
82             setObject(obj.getURI()) ;
83     }
84
85     public void setSubject(String JavaDoc subj)
86     {
87         subject = subj ;
88         super.addParam("s", subj) ;
89     }
90
91     public void setPredicate(String JavaDoc pred)
92     {
93         predicate = pred ;
94         super.addParam("p", pred) ;
95     }
96
97     public void setObject(String JavaDoc obj)
98     {
99         object = obj ;
100         super.addParam("o", obj) ;
101     }
102
103     public void setValue(String JavaDoc val)
104     {
105         value = val ;
106         super.addParam("v", val) ;
107     }
108
109     public void setClosure(boolean close)
110     {
111         closure = close ;
112         super.addParam("close", String.valueOf(close)) ;
113     }
114 }
115     
116
117 /*
118  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
119  * All rights reserved.
120  *
121  * Redistribution and use in source and binary forms, with or without
122  * modification, are permitted provided that the following conditions
123  * are met:
124  * 1. Redistributions of source code must retain the above copyright
125  * notice, this list of conditions and the following disclaimer.
126  * 2. Redistributions in binary form must reproduce the above copyright
127  * notice, this list of conditions and the following disclaimer in the
128  * documentation and/or other materials provided with the distribution.
129  * 3. The name of the author may not be used to endorse or promote products
130  * derived from this software without specific prior written permission.
131  *
132  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
133  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
134  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
135  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
136  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
137  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
138  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
139  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
140  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
141  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
142  */

143
Popular Tags