/** Compare two result sets for bNode isomorphism equivalence. * Only does RDF term comparison. */ public static boolean isomorphic(ResultSet rs1, ResultSet rs2) { Model m1 = RDFOutput.encodeAsModel(rs1) ; Model m2 = RDFOutput.encodeAsModel(rs2) ; return m1.isIsomorphicWith(m2) ; }
/** Encode the boolean as RDF in the model provided. * * @param model The place where to put the RDF. * @param booleanResult * @return Resource The resource for the result set. */ static public Resource encodeAsRDF(Model model, boolean booleanResult) { RDFOutput rOut = new RDFOutput() ; return rOut.asRDF(model, booleanResult) ; }
public Model asModel(boolean result) { Model m = GraphFactory.makeJenaDefaultModel() ; encodeAsRDF(m, result) ; addPrefixes(m) ; return m ; }
/** Write out an RDF model that encodes a boolean result * * @param format Name of RDF format (names as Jena writers) * @param booleanResult The boolean result to encode in RDF */ static public void outputAsRDF(String format, boolean booleanResult) { RDFOutput.outputAsRDF(System.out, format, booleanResult) ; }
Iterator<String> iter = getAllVars() ? rBind.varNames() : resultSet.getResultVars().iterator() ; addPrefixes(model) ; return results ;
/** Encode the result set as RDF in the model provided. * * @param model The place where to put the RDF. * @return Resource The resource for the result set. */ public Resource asRDF(Model model, ResultSet resultSet) { return asRDF(model, resultSet, false) ; }
SPARQLResult x = ReadAnything.read(filenameOrURI); if (x.isResultSet()) RDFOutput.encodeAsRDF(model, x.getResultSet()); else if ( x.isBoolean() ) RDFOutput.encodeAsRDF(model, x.getBooleanResult()); else throw new ResultSetException("Not a result set");
/** Write out an RDF model that encodes the result set * * @param format Name of RDF format (names as Jena writers) * @param resultSet The result set to encode in RDF */ static public void outputAsRDF(String format, ResultSet resultSet) { RDFOutput.outputAsRDF(System.out, format, resultSet) ; }
/** Encode the result set as RDF. * @return Model Model contains the results */ public Model asModel(ResultSet resultSet) { Model m = GraphFactory.makeJenaDefaultModel() ; asRDF(m, resultSet) ; if ( m.getNsPrefixURI("rs") == null ) m.setNsPrefix("rs", ResultSetGraphVocab.getURI() ) ; if ( m.getNsPrefixURI("rdf") == null ) m.setNsPrefix("rdf", RDF.getURI() ) ; return m ; }
/** Write out an RDF model that encodes the result set. * See also the same method taking an output stream. * * @param out Output : ideally, should be a UTF-8 print writer (not system default) * @param format Name of RDF format (names as Jena writers) * @param resultSet The result set to encode in RDF */ private static void outputAsRDF(PrintWriter out, String format, ResultSet resultSet) { Model m = RDFOutput.encodeAsModel(resultSet) ; m.write(out, format) ; out.flush() ; }
/** Encode the result set as RDF in the model provided. * * @param model The place where to put the RDF. * @param resultSet * @return Resource The resource for the result set. */ static public Resource encodeAsRDF(Model model, ResultSet resultSet) { RDFOutput rOut = new RDFOutput() ; return rOut.asRDF(model, resultSet) ; }
/** Write out an RDF model that encodes a boolean result * * @param outStream Output * @param format Name of RDF format (names as Jena writers) * @param booleanResult The boolean result to encode in RDF */ static public void outputAsRDF(OutputStream outStream, String format, boolean booleanResult) { PrintWriter out = FileUtils.asPrintWriterUTF8(outStream) ; RDFOutput.outputAsRDF(out, format, booleanResult) ; out.flush() ; }
/** Write out an RDF model that encodes a boolean result. * See also the same method taking an output stream. * * @param out Output : ideally, should be a UTF-8 print writer (not system default) * @param format Name of RDF format (names as Jena writers) * @param booleanResult The boolean result to encode in RDF */ private static void outputAsRDF(PrintWriter out, String format, boolean booleanResult) { Model m = RDFOutput.encodeAsModel(booleanResult) ; m.write(out, format) ; out.flush() ; } }
/** Write out an RDF model that encodes the result set * * @param outStream Output * @param format Name of RDF format (names as Jena writers) * @param resultSet The result set to encode in RDF */ static public void outputAsRDF(OutputStream outStream, String format, ResultSet resultSet) { PrintWriter out = FileUtils.asPrintWriterUTF8(outStream) ; RDFOutput.outputAsRDF(out, format, resultSet) ; out.flush() ; }
@Test public void test_RS_3() { ResultSetRewindable rs1 = new ResultSetMem() ; Model model = RDFOutput.encodeAsModel(rs1) ; rs1.reset() ; ResultSet rs2 = RDFInput.fromRDF(model) ; assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ; }
RDFOutput.outputAsRDF(out, "RDF/XML-ABBREV", resultSet) ; return true; RDFOutput.outputAsRDF(out, "TTL", resultSet) ; return true; RDFOutput.outputAsRDF(out, "N-TRIPLES", resultSet) ; return true;
Model actualModel = RDFOutput.encodeAsModel(results) ;
RDFOutput.outputAsRDF(System.out, "TURTLE", b) ; System.out.flush() ; return ;