/** * Writes a boolean query result document in a specific boolean query result format to an output stream. * * @param value * The value to write. * @param format * The file format of the document to write. * @param out * An OutputStream to write the document to. * @throws IOException * If an I/O error occured while writing the query result document to the stream. * @throws UnsupportedQueryResultFormatException * If an unsupported query result file format was specified. */ public static void writeBoolean(boolean value, QueryResultFormat format, OutputStream out) throws QueryResultHandlerException, UnsupportedQueryResultFormatException { BooleanQueryResultWriter writer = createBooleanWriter(format, out); writer.startDocument(); writer.startHeader(); writer.handleBoolean(value); }
BooleanQueryResultWriter qrWriter = brWriterFactory.getWriter(out); boolean value = (Boolean)model.get(QUERY_RESULT_KEY); qrWriter.handleBoolean(value);
try (BufferedOutputStream response = new BufferedOutputStream(exchange.getResponseBody())) { BooleanQueryResultWriter w = BooleanQueryResultWriterRegistry.getInstance().get(format).get().getWriter(response); w.setWriterConfig(writerConfig); w.write(((BooleanQuery) query).evaluate());
headers.set(HttpHeaders.CONTENT_TYPE, "application/sparql-results+json"); BooleanQueryResultWriter writer = new SPARQLBooleanJSONWriter(bao); writer.handleBoolean(b); result = bao.toString(); } else if (accept.contains("xml")) { headers.set(HttpHeaders.CONTENT_TYPE, "application/sparql-results+xml"); BooleanQueryResultWriter writer = new SPARQLBooleanXMLWriter(bao); writer.handleBoolean(b); result = bao.toString(); } else if (accept.contains("text")) { headers.set(HttpHeaders.CONTENT_TYPE, "text/boolean"); BooleanQueryResultWriter writer = new BooleanTextWriter(bao); writer.handleBoolean(b); result = bao.toString(); } else {
/** * Writes a boolean query result document in a specific boolean query result format to an output stream. * * @param value * The value to write. * @param format * The file format of the document to write. * @param out * An OutputStream to write the document to. * @throws IOException * If an I/O error occured while writing the query result document to the stream. * @throws UnsupportedQueryResultFormatException * If an unsupported query result file format was specified. */ public static void writeBoolean(boolean value, QueryResultFormat format, OutputStream out) throws QueryResultHandlerException, UnsupportedQueryResultFormatException { BooleanQueryResultWriter writer = createBooleanWriter(format, out); writer.startDocument(); writer.startHeader(); writer.handleBoolean(value); }