/* * Copyright Aduna (http://www.aduna-software.com/) (c) 2007. * * Licensed under the Aduna BSD-style license. */ package org.openrdf.repository.http; import java.io.IOException; import org.openrdf.http.client.HTTPClient; import org.openrdf.query.MalformedQueryException; import org.openrdf.query.QueryEvaluationException; import org.openrdf.query.QueryLanguage; import org.openrdf.query.TupleQuery; import org.openrdf.query.TupleQueryResult; import org.openrdf.query.TupleQueryResultHandler; import org.openrdf.query.TupleQueryResultHandlerException; import org.openrdf.repository.RepositoryException; /** * TupleQuery specific to the HTTP protocol. * * Methods in this class may throw the specific RepositoryException subclasses * UnautorizedException and NotAllowedException, the semantics of which are * defined by the HTTP protocol. * * @see org.openrdf.http.protocol.UnauthorizedException * @see org.openrdf.http.protocol.NotAllowedException * * @author Arjohn Kampman * @author Herko ter Horst */ public class HTTPTupleQuery extends HTTPQuery implements TupleQuery { public HTTPTupleQuery(HTTPRepositoryConnection con, QueryLanguage ql, String queryString, String baseURI) { super(con, ql, queryString, baseURI); } public TupleQueryResult evaluate() throws HTTPQueryEvaluationException { HTTPClient client = httpCon.getRepository().getHTTPClient(); try { return client.sendTupleQuery(queryLanguage, queryString, dataset, includeInferred, getBindingsArray()); } catch (IOException e) { throw new HTTPQueryEvaluationException(e.getMessage(), e); } catch (RepositoryException e) { throw new HTTPQueryEvaluationException(e.getMessage(), e); } catch (MalformedQueryException e) { throw new HTTPQueryEvaluationException(e.getMessage(), e); } } public void evaluate(TupleQueryResultHandler handler) throws QueryEvaluationException, TupleQueryResultHandlerException { HTTPClient client = httpCon.getRepository().getHTTPClient(); try { client.sendTupleQuery(queryLanguage, queryString, dataset, includeInferred, handler); } catch (IOException e) { throw new HTTPQueryEvaluationException(e.getMessage(), e); } catch (RepositoryException e) { throw new HTTPQueryEvaluationException(e.getMessage(), e); } catch (MalformedQueryException e) { throw new HTTPQueryEvaluationException(e.getMessage(), e); } } }