@Override public ResultSet read(InputStream in, Context context) { return TSVInput.fromTSV(in); } @Override public ResultSet read(Reader in, Context context) { throw new NotImplemented("Reader") ; }
private void parseTSVAsBoolean(String x, boolean expected) { byte[] b = StrUtils.asUTF8bytes(x); ByteArrayInputStream in = new ByteArrayInputStream(b); boolean actual = TSVInput.booleanFromTSV(in); Assert.assertEquals(expected, actual); } }
@Override public ResultSetRewindable readFrom(Class<ResultSetRewindable> type, Type type1, Annotation[] antns, javax.ws.rs.core.MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream in) throws IOException { if (log.isTraceEnabled()) log.trace("Reading ResultSet with HTTP headers: {} MediaType: {}", httpHeaders, mediaType); // result set needs to be rewindable because results might be processed multiple times, e.g. to calculate hash and write response // TO-DO: construct Jena's ResultFormat and then pass to ResultSet.load(in, format) if (mediaType.isCompatible(com.atomgraph.core.MediaType.APPLICATION_SPARQL_RESULTS_XML_TYPE)) return ResultSetFactory.makeRewindable(ResultSetFactory.fromXML(in)); if (mediaType.isCompatible(com.atomgraph.core.MediaType.APPLICATION_SPARQL_RESULTS_JSON_TYPE)) return ResultSetFactory.makeRewindable(ResultSetFactory.fromJSON(in)); if (mediaType.isCompatible(com.atomgraph.core.MediaType.APPLICATION_SPARQL_RESULTS_CSV_TYPE)) return ResultSetFactory.makeRewindable(CSVInput.fromCSV(in)); if (mediaType.isCompatible(com.atomgraph.core.MediaType.APPLICATION_SPARQL_RESULTS_CSV_TYPE)) return ResultSetFactory.makeRewindable(TSVInput.fromTSV(in)); throw new IllegalStateException("ResultSet MediaType should be readable but no Jena reader matched"); }