/** * Output a result set in a text format. The result set is consumed. * Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one. * <p> * This caches the entire results in memory in order to determine the appropriate * column widths and therefore may exhaust memory for large results * </p> * @param out OutputStream * @param qresults result set */ public static void out(OutputStream out, ResultSet qresults) { out(out, qresults, (PrefixMapping)null) ; }
/** * Output a result set in a text format. The result set is consumed. * Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one. * <p> * This caches the entire results in memory in order to determine the appropriate * column widths and therefore may exhaust memory for large results * </p> * @param qresults result set */ public static void out(ResultSet qresults) { out(System.out, qresults) ; }
/** * Output a result set in a text format. The result set is consumed. * Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one. * <p> * This caches the entire results in memory in order to determine the appropriate * column widths and therefore may exhaust memory for large results * </p> * @param qresults result set * @param prologue May be used to abbreviate URIs */ public static void out(ResultSet qresults, Prologue prologue) { out(System.out, qresults, prologue) ; }
/** * Output a result set in a text format. The result set is consumed. * Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one. * <p> * This caches the entire results in memory in order to determine the appropriate * column widths and therefore may exhaust memory for large results * </p> * @param qresults result set * @param pmap Prefix mapping for abbreviating URIs. */ public static void out(ResultSet qresults, PrefixMapping pmap) { out(System.out, qresults, pmap) ; }
/** * Output an ASK answer * @param answer The boolean answer */ public static void out(boolean answer) { out(System.out, answer) ; }
/** * Output a result set in a text format. The result set is consumed. * Use @see{ResultSetFactory.makeRewindable(ResultSet)} for a rewindable one. * <p> * This caches the entire results in memory in order to determine the appropriate * column widths and therefore may exhaust memory for large results * </p> * @param qresults result set * @param query May be used to abbreviate URIs */ public static void out(ResultSet qresults, Query query) { out(System.out, qresults, query) ; }
private static void textOutput(HttpAction action, String contentType, ResultSet resultSet, Prologue qPrologue, Boolean booleanResult) { // Text is not streaming. OutputContent proc = (ServletOutputStream out) -> { if ( resultSet != null ) ResultSetFormatter.out(out, resultSet, qPrologue) ; if ( booleanResult != null ) ResultSetFormatter.out(out, booleanResult.booleanValue()) ; }; output(action, contentType, charsetUTF8, proc) ; }
private static void textOutput(HttpAction action, String contentType, ResultSet resultSet, Prologue qPrologue, Boolean booleanResult) { // Text is not streaming. OutputContent proc = (ServletOutputStream out) -> { if ( resultSet != null ) ResultSetFormatter.out(out, resultSet, qPrologue) ; if ( booleanResult != null ) ResultSetFormatter.out(out, booleanResult.booleanValue()) ; }; output(action, contentType, charsetUTF8, proc) ; }
/** Return a string that has the result set serialized as a text table * <p> * This caches the entire results in memory in order to determine the appropriate * column widths and therefore may exhaust memory for large results * </p> * * @param qresults result set * @return string */ public static String asText(ResultSet qresults) { ByteArrayOutputStream arr = new ByteArrayOutputStream() ; out(arr, qresults) ; return new String(arr.toByteArray(), StandardCharsets.UTF_8) ; }
public static void printQueryResults(final String header, final QueryExecution qe, final Query query) { System.out.println(header); final ResultSet results = qe.execSelect(); ResultSetFormatter.out(System.out, results, query); System.out.println(); } }
public static void printQueryResults(final String header, final QueryExecution qe, final Query query) { System.out.println(header); final ResultSet results = qe.execSelect(); ResultSetFormatter.out(System.out, results, query); System.out.println(); } }
/** Return a string that has the result set serialized as a text table * <p> * This caches the entire results in memory in order to determine the appropriate * column widths and therefore may exhaust memory for large results * </p> * * @param qresults result set * @param prologue Prologue, used to abbreviate IRIs * @return string */ public static String asText(ResultSet qresults, Prologue prologue) { ByteArrayOutputStream arr = new ByteArrayOutputStream() ; out(arr, qresults, prologue) ; try { return new String(arr.toByteArray(), "UTF-8") ; } catch (UnsupportedEncodingException e) { Log.warn(ResultSetFormatter.class, "UnsupportedEncodingException") ; return null ; } }
public void dump() { QueryIterator qIter = iterator() ; ResultSetFormatter.out(ResultSetFactory.create(qIter, Var.varNames(vars))) ; }
private static void dump(Table table) { System.out.println("Table: "+Lib.className(table)) ; QueryIterator qIter = table.iterator(null) ; ResultSet rs = new ResultSetStream(table.getVarNames(), null, table.iterator(null)) ; ResultSetFormatter.out(rs) ; } }
/** * Method processes a SELECT query on a local ontModel and prints the result to the console. * * @param query is the SELECT query. * @param ontModel is the local ontModel, which should be asked. * @throws JenaException is thrown in case the SELECT query could not executed. */ static void selectQuery(final String query, final OntModel ontModel) throws JenaException { Query queryObj = QueryFactory.create(query); QueryExecution queryExecution = QueryExecutionFactory.create(queryObj, ontModel); ResultSet resultSet = queryExecution.execSelect(); ResultSetFormatter.out(System.out, resultSet, queryObj); queryExecution.close(); }
private static void same(ResultSet rs1, ResultSet rs2, boolean result) { ResultSetRewindable rsw1 = ResultSetFactory.makeRewindable(rs1) ; ResultSetRewindable rsw2 = ResultSetFactory.makeRewindable(rs2) ; boolean b = ResultSetCompare.equalsByValue(rsw1, rsw2) ; if ( b != result) { System.out.println("Different: ") ; rsw1.reset() ; rsw2.reset() ; ResultSetFormatter.out(rsw1) ; ResultSetFormatter.out(rsw2) ; System.out.println() ; } assertTrue(b == result) ; }
private static void same(ResultSet rs1, ResultSet rs2, boolean result) { ResultSetRewindable rsw1 = ResultSetFactory.makeRewindable(rs1) ; ResultSetRewindable rsw2 = ResultSetFactory.makeRewindable(rs2) ; boolean b = ResultSetCompare.equalsByValue(rsw1, rsw2) ; if ( b != result) { System.out.println("Different: ") ; rsw1.reset() ; rsw2.reset() ; ResultSetFormatter.out(rsw1) ; ResultSetFormatter.out(rsw2) ; System.out.println() ; } assertTrue(b == result) ; }
private static void same(ResultSet rs1, ResultSet rs2, boolean result) { ResultSetRewindable rsw1 = ResultSetFactory.makeRewindable(rs1) ; ResultSetRewindable rsw2 = ResultSetFactory.makeRewindable(rs2) ; boolean b = ResultSetCompare.equalsByValue(rsw1, rsw2) ; if ( b != result) { System.out.println("Different: ") ; rsw1.reset() ; rsw2.reset() ; ResultSetFormatter.out(rsw1) ; ResultSetFormatter.out(rsw2) ; System.out.println() ; } assertTrue(b == result) ; }
private static void same(ResultSet rs1, ResultSet rs2, boolean result) { ResultSetRewindable rsw1 = ResultSetFactory.makeRewindable(rs1) ; ResultSetRewindable rsw2 = ResultSetFactory.makeRewindable(rs2) ; boolean b = ResultSetCompare.equalsByValue(rsw1, rsw2) ; if ( b != result) { System.out.println("Different: ") ; rsw1.reset() ; rsw2.reset() ; ResultSetFormatter.out(rsw1) ; ResultSetFormatter.out(rsw2) ; System.out.println() ; } assertTrue(b == result) ; }
@Test public void test_RS_4() { ResultSetRewindable rs1 = makeRewindable("x", org.apache.jena.graph.NodeFactory.createURI("tag:local")) ; Model model = RDFOutput.encodeAsModel(rs1) ; rs1.reset() ; ResultSetRewindable rs2 = ResultSetFactory.makeRewindable(RDFInput.fromRDF(model)) ; boolean b = ResultSetCompare.equalsByTerm(rs1, rs2) ; if ( ! b ) { rs1.reset() ; rs2.reset() ; ResultSetFormatter.out(rs1) ; ResultSetFormatter.out(rs2) ; } assertTrue(b) ; }