@Override public void startRDF() throws RDFHandlerException { if (writingStarted) { throw new RuntimeException("Document writing has already started"); } writingStarted = true; xsdStringToPlainLiteral = getWriterConfig().get(BasicWriterSettings.XSD_STRING_TO_PLAIN_LITERAL); escapeUnicode = getWriterConfig().get(NTriplesWriterSettings.ESCAPE_UNICODE); }
@Override public <T> RDFWriter set(RioSetting<T> setting, T value) { getWriterConfig().set(setting, value); return this; } }
/** * @param connection connection to Sail repository * @param storedQueries pre-defined stored SPARQL query templates * @param writerProperties RDF4J RIO WriterConfig properties * @param verbose true when verbose mode enabled, otherwise false */ @SuppressWarnings("unchecked") public HttpSparqlHandler(SailRepositoryConnection connection, Properties storedQueries, Properties writerProperties, boolean verbose) { this.connection = connection; if (!verbose) { // Verbose mode disabled --> logs with level lower than WARNING will be discarded LOGGER.setLevel(Level.WARNING); } this.storedQueries = storedQueries; this.writerConfig = new WriterConfig(); if (writerProperties != null) { for (Map.Entry<Object, Object> me : writerProperties.entrySet()) { writerConfig.set((RioSetting) getStaticField(me.getKey().toString()), getStaticField(me.getValue().toString())); } } }
/** * Writes the given single statement to the given {@link Writer} in the given format. * <p> * * @param statement * A statement to be written. * @param output * The {@link Writer} to write the statement to. * @param dataFormat * The {@link RDFFormat} to use when writing the statement. * @throws RDFHandlerException * Thrown if there is an error writing the statement. * @throws UnsupportedRDFormatException * If no {@link RDFWriter} is available for the specified RDF format. */ public static void write(Statement statement, Writer output, RDFFormat dataFormat) throws RDFHandlerException { write(statement, output, dataFormat, new WriterConfig()); }
protected void endDocument() throws IOException { jg.writeEndObject(); if (getWriterConfig().isSet(BasicQueryWriterSettings.JSONP_CALLBACK)) { jg.writeRaw(");"); } jg.flush(); documentOpen = false; headerOpen = false; headerComplete = false; tupleVariablesFound = false; firstTupleWritten = false; linksFound = false; }
/** * Writes the given statement to the given {@link OutputStream} in the given format. * <p> * * @param st * The statement to be written. * @param output * The {@link OutputStream} to write the statement to. * @param dataFormat * The {@link RDFFormat} to use when writing the statement. * @throws RDFHandlerException * Thrown if there is an error writing the statement. * @throws UnsupportedRDFormatException * If no {@link RDFWriter} is available for the specified RDF format. */ public static void write(Statement st, OutputStream output, RDFFormat dataFormat) throws RDFHandlerException { write(st, output, dataFormat, new WriterConfig()); }
protected void endDocument() throws IOException { jg.writeEndObject(); if (getWriterConfig().isSet(BasicQueryWriterSettings.JSONP_CALLBACK)) { jg.writeRaw(");"); } jg.flush(); documentOpen = false; headerOpen = false; headerComplete = false; tupleVariablesFound = false; firstTupleWritten = false; linksFound = false; }
@Override public void startRDF() throws RDFHandlerException { if (writingStarted) { throw new RuntimeException("Document writing has already started"); } writingStarted = true; xsdStringToPlainLiteral = getWriterConfig().get(BasicWriterSettings.XSD_STRING_TO_PLAIN_LITERAL); escapeUnicode = getWriterConfig().get(NTriplesWriterSettings.ESCAPE_UNICODE); }
@Override public <T> RDFWriter set(RioSetting<T> setting, T value) { getWriterConfig().set(setting, value); return this; } }
/** * Writes the given statement to the given {@link OutputStream} in the given format. * <p> * * @param st * The statement to be written. * @param output * The {@link OutputStream} to write the statement to. * @param dataFormat * The {@link RDFFormat} to use when writing the statement. * @throws RDFHandlerException * Thrown if there is an error writing the statement. * @throws UnsupportedRDFormatException * If no {@link RDFWriter} is available for the specified RDF format. */ public static void write(Statement st, OutputStream output, RDFFormat dataFormat) throws RDFHandlerException { write(st, output, dataFormat, new WriterConfig()); }
protected boolean xsdStringToPlainLiteral() { return getWriterConfig().get(BasicWriterSettings.XSD_STRING_TO_PLAIN_LITERAL); } }
@Override public <T> RDFWriter set(RioSetting<T> setting, T value) { getWriterConfig().set(setting, value); return this; } }
/** * Writes the given statements to the given {@link OutputStream} in the given format. * <p> * If the collection is a {@link Model}, its namespaces will also be written. * * @param model * A collection of statements, such as a {@link Model}, to be written. * @param output * The {@link OutputStream} to write the statements to. * @param dataFormat * The {@link RDFFormat} to use when writing the statements. * @throws RDFHandlerException * Thrown if there is an error writing the statements. * @throws UnsupportedRDFormatException * If no {@link RDFWriter} is available for the specified RDF format. */ public static void write(Iterable<Statement> model, OutputStream output, RDFFormat dataFormat) throws RDFHandlerException { write(model, output, dataFormat, new WriterConfig()); }
protected boolean xsdStringToPlainLiteral() { return getWriterConfig().get(BasicWriterSettings.XSD_STRING_TO_PLAIN_LITERAL); } }
/** * Enables/disables addition of indentation characters and newlines in the XML document. By default, * pretty-printing is set to <tt>true</tt>. If set to <tt>false</tt>, no indentation and newlines are * added to the XML document. This method has to be used before writing starts (that is, before * {@link #startDocument} is called). * * @deprecated Use {@link #getWriterConfig()} .set(BasicWriterSettings.PRETTY_PRINT, prettyPrint) instead. */ @Deprecated public void setPrettyPrint(boolean prettyPrint) { getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, prettyPrint); xmlWriter.setPrettyPrint(prettyPrint); }
/** * Writes the given single statement to the given {@link Writer} in the given format. * <p> * * @param statement * A statement to be written. * @param output * The {@link Writer} to write the statement to. * @param dataFormat * The {@link RDFFormat} to use when writing the statement. * @throws RDFHandlerException * Thrown if there is an error writing the statement. * @throws UnsupportedRDFormatException * If no {@link RDFWriter} is available for the specified RDF format. */ public static void write(Statement statement, Writer output, RDFFormat dataFormat) throws RDFHandlerException { write(statement, output, dataFormat, new WriterConfig()); }
public void startRDF() throws RDFHandlerException { if (getWriterConfig().get(BasicWriterSettings.INLINE_BLANK_NODES)) { targetQueueSize = -1; repeatBlankNodes = true; } else if (getWriterConfig().get(BasicWriterSettings.PRETTY_PRINT)) { targetQueueSize = DEFAULT_QUEUE_SIZE; } delegate.startRDF(); }
/** * Enables/disables addition of indentation characters and newlines in the XML document. By default, * pretty-printing is set to <tt>true</tt>. If set to <tt>false</tt>, no indentation and newlines are * added to the XML document. This method has to be used before writing starts (that is, before * {@link #startDocument} is called). * * @deprecated Use {@link #getWriterConfig()} .set(BasicWriterSettings.PRETTY_PRINT, prettyPrint) instead. */ @Deprecated public void setPrettyPrint(boolean prettyPrint) { getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, prettyPrint); xmlWriter.setPrettyPrint(prettyPrint); }