@Test public void ask() throws IOException { final SparqlClient sparqlClient = new SparqlClient( "http: Object result = sparqlClient.queryResult( "ASK { " + "<http: + "<http: Assert.assertEquals("ASK should result to true", Boolean.TRUE, result); }
public Object queryResult(final String query) throws IOException { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(endpoint); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("query", query)); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response2 = httpclient.execute(httpPost); HttpEntity entity2 = response2.getEntity(); try { InputStream in = entity2.getContent(); final String mediaType = entity2.getContentType().getValue(); if (mediaType.startsWith("application/sparql-results+xml")) { return SparqlResultParser.parse(in); } else { Parser parser = Parser.getInstance(); return parser.parse(in, mediaType); } } finally { EntityUtils.consume(entity2); response2.close(); } }
SparqlClient { public Object queryResult(final String query) throws IOException { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(endpoint); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("query", query)); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response2 = httpclient.execute(httpPost); HttpEntity entity2 = response2.getEntity(); try { InputStream in = entity2.getContent(); final String mediaType = entity2.getContentType().getValue(); if (mediaType.startsWith("application/sparql-results+xml")) { return SparqlResultParser.parse(in); } else { Parser parser = Parser.getInstance(); return parser.parse(in, mediaType); } } finally { EntityUtils.consume(entity2); response2.close(); } } }
SparqlClient { public Object queryResult(final String query) throws IOException { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(endpoint); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("query", query)); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response2 = httpclient.execute(httpPost); HttpEntity entity2 = response2.getEntity(); try { InputStream in = entity2.getContent(); final String mediaType = entity2.getContentType().getValue(); if (mediaType.startsWith("application/sparql-results+xml")) { return SparqlResultParser.parse(in); } else { Parser parser = Parser.getInstance(); return parser.parse(in, mediaType); } } finally { EntityUtils.consume(entity2); response2.close(); } } SparqlClient(final String endpoint); }
SparqlClient { public Object queryResult(final String query) throws IOException { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(endpoint); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("query", query)); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response2 = httpclient.execute(httpPost); HttpEntity entity2 = response2.getEntity(); try { InputStream in = entity2.getContent(); final String mediaType = entity2.getContentType().getValue(); if (mediaType.startsWith("application/sparql-results+xml")) { return SparqlResultParser.parse(in); } else { Parser parser = Parser.getInstance(); return parser.parse(in, mediaType); } } finally { EntityUtils.consume(entity2); response2.close(); } } SparqlClient(final String endpoint); List<Map<String, RDFTerm>> queryResultSet(final String query); Object queryResult(final String query); }
SparqlClient { public Object queryResult(final String query) throws IOException { CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(endpoint); List<NameValuePair> nvps = new ArrayList<NameValuePair>(); nvps.add(new BasicNameValuePair("query", query)); httpPost.setEntity(new UrlEncodedFormEntity(nvps)); CloseableHttpResponse response2 = httpclient.execute(httpPost); HttpEntity entity2 = response2.getEntity(); try { InputStream in = entity2.getContent(); final String mediaType = entity2.getContentType().getValue(); if (mediaType.startsWith("application/sparql-results+xml")) { return SparqlResultParser.parse(in); } else { Parser parser = Parser.getInstance(); return parser.parse(in, mediaType); } } finally { EntityUtils.consume(entity2); response2.close(); } } SparqlClient(final String endpoint); List<Map<String, RDFTerm>> queryResultSet(final String query); Object queryResult(final String query);  }