KickJava   Java API By Example, From Geeks To Geeks.

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


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

5
6 package com.hp.hpl.jena.joseki;
7
8 import org.apache.commons.logging.* ;
9
10 import com.hp.hpl.jena.rdf.model.* ;
11
12 /** Execution object for a "fetch" over HTTP.
13  * The exact results returned wil depend on the server, which will have
14  * "fetch handlers" on remote model. The defintion of a "fetch hanlder"
15  * is server-dependent.
16  *
17  * There are two ways to identifiy the resource: either by its URI,
18  * or by a property/value that identifies the resource.
19  *
20  * @author Andy Seaborne
21  * @version $Id: HttpFetch.java,v 1.5 2004/04/30 14:13:13 andy_seaborne Exp $
22  */

23
24 public class HttpFetch extends HttpQuery
25 {
26     static final Log logger = LogFactory.getLog(HttpFetch.class.getName()) ;
27     
28     /** Perform a fetch operation in the named model on the named resource.
29      *
30      * @param url Remote model
31      * @param resource Named resource - must have a URI
32      */

33     
34     public HttpFetch(String JavaDoc url, Resource resource)
35     {
36         super(url, "fetch") ;
37         addParam("r", resource.getURI()) ;
38     }
39
40     /** Perform a fetch operation in the named model on the named resource
41      *
42      * @param url Remote model
43      * @param resourceURI Resource URI
44      */

45     public HttpFetch(String JavaDoc url, String JavaDoc resourceURI)
46     {
47         super(url, "fetch") ;
48         addParam("r", resourceURI) ;
49     }
50     
51     /** Perform a fetch on a resource identified by predicate and value.
52      *
53      * @param url Remote model.
54      * @param predicate Property
55      * @param value Resource (with URI) or Literal (plain literal)
56      */

57     public HttpFetch(String JavaDoc url, Property predicate, RDFNode value)
58     {
59         super(url, "fetch") ;
60         addParam("p", predicate.getURI()) ;
61         if ( value instanceof Resource)
62             addParam("o", ((Resource)value).getURI() ) ;
63         else
64             addParam("v", ((Literal)value).getLexicalForm()) ;
65     }
66
67     /** Perform a fetch on a resource identified by predciate and value.
68      *
69      * @param url Remote model
70      * @param predicateURI Predicate URI
71      * @param objURIorValue String - either URI or literal value
72      * @param isURI Indicator for of kind of object
73      */

74
75     public HttpFetch(String JavaDoc url, String JavaDoc predicateURI, String JavaDoc objURIorValue, boolean isURI)
76     {
77         super(url, "fetch") ;
78         addParam("p", predicateURI) ;
79         if ( isURI )
80             addParam("o", objURIorValue) ;
81         else
82             addParam("v", objURIorValue) ;
83     }
84     
85
86 }
87
88 /*
89  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
90  * All rights reserved.
91  *
92  * Redistribution and use in source and binary forms, with or without
93  * modification, are permitted provided that the following conditions
94  * are met:
95  * 1. Redistributions of source code must retain the above copyright
96  * notice, this list of conditions and the following disclaimer.
97  * 2. Redistributions in binary form must reproduce the above copyright
98  * notice, this list of conditions and the following disclaimer in the
99  * documentation and/or other materials provided with the distribution.
100  * 3. The name of the author may not be used to endorse or promote products
101  * derived from this software without specific prior written permission.
102  *
103  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
104  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
105  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
106  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
107  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
108  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
109  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
110  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
111  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
112  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113  */

114
Popular Tags