01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.repository.http;
07:
08: import java.io.IOException;
09:
10: import org.openrdf.http.client.HTTPClient;
11: import org.openrdf.query.MalformedQueryException;
12: import org.openrdf.query.QueryEvaluationException;
13: import org.openrdf.query.QueryLanguage;
14: import org.openrdf.query.TupleQuery;
15: import org.openrdf.query.TupleQueryResult;
16: import org.openrdf.query.TupleQueryResultHandler;
17: import org.openrdf.query.TupleQueryResultHandlerException;
18: import org.openrdf.repository.RepositoryException;
19:
20: /**
21: * TupleQuery specific to the HTTP protocol.
22: *
23: * Methods in this class may throw the specific RepositoryException subclasses
24: * UnautorizedException and NotAllowedException, the semantics of which are
25: * defined by the HTTP protocol.
26: *
27: * @see org.openrdf.http.protocol.UnauthorizedException
28: * @see org.openrdf.http.protocol.NotAllowedException
29: *
30: * @author Arjohn Kampman
31: * @author Herko ter Horst
32: */
33: public class HTTPTupleQuery extends HTTPQuery implements TupleQuery {
34:
35: public HTTPTupleQuery(HTTPRepositoryConnection con,
36: QueryLanguage ql, String queryString, String baseURI) {
37: super (con, ql, queryString, baseURI);
38: }
39:
40: public TupleQueryResult evaluate()
41: throws HTTPQueryEvaluationException {
42: HTTPClient client = httpCon.getRepository().getHTTPClient();
43:
44: try {
45: return client.sendTupleQuery(queryLanguage, queryString,
46: dataset, includeInferred, getBindingsArray());
47: } catch (IOException e) {
48: throw new HTTPQueryEvaluationException(e.getMessage(), e);
49: } catch (RepositoryException e) {
50: throw new HTTPQueryEvaluationException(e.getMessage(), e);
51: } catch (MalformedQueryException e) {
52: throw new HTTPQueryEvaluationException(e.getMessage(), e);
53: }
54: }
55:
56: public void evaluate(TupleQueryResultHandler handler)
57: throws QueryEvaluationException,
58: TupleQueryResultHandlerException {
59: HTTPClient client = httpCon.getRepository().getHTTPClient();
60: try {
61: client.sendTupleQuery(queryLanguage, queryString, dataset,
62: includeInferred, handler);
63: } catch (IOException e) {
64: throw new HTTPQueryEvaluationException(e.getMessage(), e);
65: } catch (RepositoryException e) {
66: throw new HTTPQueryEvaluationException(e.getMessage(), e);
67: } catch (MalformedQueryException e) {
68: throw new HTTPQueryEvaluationException(e.getMessage(), e);
69: }
70: }
71: }
|