/** * Load a result set from file or URL into a result set (memory backed). * * @param filenameOrURI * @return ResultSet */ public static ResultSet load(String filenameOrURI) { return load(filenameOrURI, null); }
@Override public void handle(String baseIRI, HttpResponse response) throws IOException { String ct = contentType(response); ResultsFormat fmt = contentTypeToResultsFormat(ct); InputStream in = response.getEntity().getContent(); rs = ResultSetFactory.load(in, fmt); // Force reading rs = ResultSetFactory.copyResults(rs); }
public static ResultSet parseResultSet(final String resultURI) throws IOException { if (resultURI.endsWith("srx")) return ResultSetFactory.fromXML(URI.create(resultURI).toURL().openStream()); else if (resultURI.endsWith("ttl")) return ResultSetFactory.load(resultURI, ResultsFormat.FMT_RDF_TTL); else if (resultURI.endsWith("rdf")) return ResultSetFactory.load(resultURI, ResultsFormat.FMT_RDF_XML); else throw new OpenError("Unknown format."); }
public static ResultSet parseResultSet(final String resultURI) throws IOException { if (resultURI.endsWith("srx")) return ResultSetFactory.fromXML(URI.create(resultURI).toURL().openStream()); else if (resultURI.endsWith("ttl")) return ResultSetFactory.load(resultURI, ResultsFormat.FMT_RDF_TTL); else if (resultURI.endsWith("rdf")) return ResultSetFactory.load(resultURI, ResultsFormat.FMT_RDF_XML); else throw new OpenError("Unknown format."); }
public static ResultSet parseResultSet(final String resultURI) throws IOException { if (resultURI.endsWith("srx")) return ResultSetFactory.fromXML(URI.create(resultURI).toURL().openStream()); else if (resultURI.endsWith("ttl")) return ResultSetFactory.load(resultURI, ResultsFormat.FMT_RDF_TTL); else if (resultURI.endsWith("rdf")) return ResultSetFactory.load(resultURI, ResultsFormat.FMT_RDF_XML); else throw new OpenError("Unknown format."); }
/** * Load a result set from file or URL into a result set (memory backed). * * @param filenameOrURI * @param format * @return ResultSet */ public static ResultSet load(String filenameOrURI, ResultsFormat format) { if (format == null) format = ResultsFormat.guessSyntax(filenameOrURI); InputStream in = IO.openFile(filenameOrURI) ; return load(in, format) ; }
@Test public void rs_xmllang_datatype_1() { ResultSetFactory.load(DIR + "rs-xmllang-datatype-1.srj"); }
@Test(expected=ResultSetException.class) public void rs_xmllang_datatype_2() { // Bad: datatype is not rdf:langString (it is xsd:string in the test data) ResultSetFactory.load(DIR + "rs-xmllang-datatype-2.srj"); }
@Test public void rs_datatype_string() { ResultSet rs = ResultSetFactory.load(DIR + "rs-datatype-string.srj"); }
@Test public void test_RS_8() { ResultSet rs = ResultSetFactory.load(DIR+"output.srx") ; test_RS_fmt(rs, ResultsFormat.FMT_RS_JSON, true) ; }
@Test public void test_RS_7() { ResultSet rs = ResultSetFactory.load(DIR+"output.srx") ; test_RS_fmt(rs, ResultsFormat.FMT_RS_XML, true) ; }
@Test public void test_RS_9() { ResultSet rs = ResultSetFactory.load(DIR+"output.srx") ; test_RS_fmt(rs, ResultsFormat.FMT_RDF_XML, false) ; }
@Override public InputStream sparqlSelectQuery(String query, ResultFormat resultFormat) throws RDFServiceException { ResultSet rs = ResultSetFactory.load( s.sparqlSelectQuery(query, resultFormat), RDFServiceUtils.getJenaResultSetFormat(resultFormat));
@Test public void test_RS_10() { ResultSet rs = ResultSetFactory.load(DIR+"output.srx") ; for ( ; rs.hasNext(); rs.next()) { } // We should be able to call hasNext() as many times as we want! assertFalse(rs.hasNext()); }
private void test_RS_fmt(ResultSet rs, ResultsFormat fmt, boolean ordered) { ResultSetRewindable rs1 = ResultSetFactory.makeRewindable(rs) ; ByteArrayOutputStream arr = new ByteArrayOutputStream() ; ResultSetFormatter.output(arr, rs1, fmt) ; byte bytes[] = arr.toByteArray() ; rs1.reset() ; ByteArrayInputStream ins = new ByteArrayInputStream(bytes) ; ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(ResultSetFactory.load(ins, fmt)) ; // Ordered? Unordered? boolean b = ResultSetCompare.equalsByTerm(rs1, rs2) ; if ( ordered ) { rs1.reset() ; rs2.reset() ; b = b & ResultSetCompare.equalsByTerm(rs1, rs2) ; } if ( !b ) { System.out.println(new String(bytes)) ; rs1.reset() ; rs2.reset() ; ResultSetFormatter.out(rs1) ; ResultSetFormatter.out(rs2) ; } assertTrue(b) ; } // Test comparison