use of org.apache.jena.sparql.ARQException in project jena by apache.
the class QueryEngineHTTP method makeHttpQuery.
private HttpQuery makeHttpQuery() {
if (closed)
throw new ARQException("HTTP execution already closed");
HttpQuery httpQuery = new HttpQuery(service);
httpQuery.merge(getServiceParams(service, context));
httpQuery.addParam(HttpParams.pQuery, queryString);
for (String dft : defaultGraphURIs) {
httpQuery.addParam(HttpParams.pDefaultGraph, dft);
}
for (String name : namedGraphURIs) {
httpQuery.addParam(HttpParams.pNamedGraph, name);
}
if (params != null)
httpQuery.merge(params);
httpQuery.setAllowCompression(allowCompression);
// check for service context overrides
if (context.isDefined(Service.serviceContext)) {
Map<String, Context> servicesContext = context.get(Service.serviceContext);
if (servicesContext.containsKey(service)) {
Context serviceContext = servicesContext.get(service);
if (serviceContext.isDefined(Service.queryClient))
client = serviceContext.get(Service.queryClient);
}
}
httpQuery.setClient(client);
HttpClientContext hcc = (httpContext == null) ? null : HttpClientContext.adapt(httpContext);
httpQuery.setContext(hcc);
// Apply timeouts
if (connectTimeout > 0)
httpQuery.setConnectTimeout((int) connectTimeoutUnit.toMillis(connectTimeout));
if (readTimeout > 0)
httpQuery.setReadTimeout((int) readTimeoutUnit.toMillis(readTimeout));
return httpQuery;
}
use of org.apache.jena.sparql.ARQException in project jena by apache.
the class TSVInput method fromTSV.
/**
* Reads SPARQL Results from TSV format into a {@link ResultSet} instance
* @param in Input Stream
*/
public static ResultSet fromTSV(InputStream in) {
BufferedReader reader = IO.asBufferedUTF8(in);
List<Var> vars = new ArrayList<>();
List<String> varNames = new ArrayList<>();
String str = null;
try {
// Here we try to parse only the Header Row
str = reader.readLine();
if (str == null)
throw new ARQException("TSV Results malformed, input is empty (no header row)");
if (!str.isEmpty()) {
String[] tokens = pattern.split(str, -1);
for (String token : tokens) {
Node v;
try {
v = NodeFactoryExtra.parseNode(token);
if (v == null || !v.isVariable())
throw new ResultSetException("TSV Results malformed, not a variable: " + token);
} catch (RiotException ex) {
throw new ResultSetException("TSV Results malformed, variable names must begin with a ? in the header: " + token);
}
Var var = Var.alloc(v);
vars.add(var);
varNames.add(var.getName());
}
}
} catch (IOException ex) {
throw new ARQException(ex);
}
//This will parse actual result rows as needed thus minimising memory usage
return new ResultSetStream(varNames, null, new TSVInputIterator(reader, vars));
}
use of org.apache.jena.sparql.ARQException in project jena by apache.
the class TSVOutput method format.
@Override
public void format(OutputStream out, boolean booleanResult) {
try {
out.write(headerBytes);
if (booleanResult)
out.write(yesBytes);
else
out.write(noBytes);
out.write(NLBytes);
} catch (IOException ex) {
throw new ARQException(ex);
}
}
use of org.apache.jena.sparql.ARQException in project jena by apache.
the class TestSSE_Basic method parseBad.
private void parseBad(String str) {
try {
Item item = SSE.parse(str);
//System.out.println(str+" => "+item) ;
fail("Did not get a parse failure");
} catch (ARQException ex) {
}
}
use of org.apache.jena.sparql.ARQException in project jena by apache.
the class TestSSE_Basic method parseBadNode.
private void parseBadNode(String str) {
try {
// Not NodeFactory.parseNode which does not have all the features (e.g. "_" and "?")
Node node = parseNode(str);
//System.out.println(str+" => "+item) ;
fail("Did not get a parse failure");
}//catch (RiotException ex) {}
catch (ARQException ex) {
}
}
Aggregations