Package org.eclipse.rdf4j.rio
Class Rio
java.lang.Object
org.eclipse.rdf4j.rio.Rio
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic RDFParser
createParser
(RDFFormat format) Convenience methods for creating RDFParser objects.This method uses the registry returned byRDFParserRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate parser.static RDFParser
createParser
(RDFFormat format, ValueFactory valueFactory) Convenience methods for creating RDFParser objects that use the specified ValueFactory to create RDF model objects.static RDFWriter
createWriter
(RDFFormat format, OutputStream out) Convenience methods for creating RDFWriter objects.This method uses the registry returned byRDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate writer.static RDFWriter
createWriter
(RDFFormat format, OutputStream out, String baseURI) Convenience methods for creating RDFWriter objects.This method uses the registry returned byRDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate writer.static RDFWriter
createWriter
(RDFFormat format, Writer writer) Convenience methods for creating RDFWriter objects.This method uses the registry returned byRDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate writer.static RDFWriter
createWriter
(RDFFormat format, Writer writer, String baseURI) Convenience methods for creating RDFWriter objects.This method uses the registry returned byRDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate writer.getParserFormatForFileName
(String fileName) Tries to match the extension of a file name against the list of RDF formats that can be parsed.getParserFormatForMIMEType
(String mimeType) Tries to match a MIME type against the list of RDF formats that can be parsed.getWriterFormatForFileName
(String fileName) Tries to match the extension of a file name against the list of RDF formats that can be written.getWriterFormatForMIMEType
(String mimeType) Tries to match a MIME type against the list of RDF formats that can be written.static void
static Model
parse
(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.static Model
parse
(InputStream in, String baseURI, RDFFormat dataFormat, ParserConfig settings, Resource... contexts) Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.static Model
parse
(InputStream in, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, ModelFactory modelFactory, Resource... contexts) Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.static Model
parse
(InputStream in, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, Resource... contexts) Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.static Model
parse
(InputStream in, RDFFormat dataFormat, Resource... contexts) Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.static Model
parse
(InputStream in, RDFFormat dataFormat, ParserConfig settings, Resource... contexts) Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.static Model
static Model
parse
(Reader reader, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, ModelFactory modelFactory, Resource... contexts) static Model
parse
(Reader reader, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, Resource... contexts) static Model
static Model
parse
(Reader reader, RDFFormat dataFormat, ParserConfig settings, Resource... contexts) static Supplier
<UnsupportedRDFormatException> unsupportedFormat
(String unsupportedFormat) Helper method to use to create a lambda forOptional.orElseThrow(Supplier)
to indicate a format is unsupported.static Supplier
<UnsupportedRDFormatException> unsupportedFormat
(RDFFormat unsupportedFormat) Helper method to use to create a lambda forOptional.orElseThrow(Supplier)
to indicate a format is unsupported.static void
Writes the given statements to the givenOutputStream
in the given format.static void
write
(Iterable<Statement> model, OutputStream output, String baseURI, RDFFormat dataFormat, WriterConfig settings) Writes the given statements to the givenOutputStream
in the given format.static void
write
(Iterable<Statement> model, OutputStream output, RDFFormat dataFormat) Writes the given statements to the givenOutputStream
in the given format.static void
write
(Iterable<Statement> model, OutputStream output, RDFFormat dataFormat, WriterConfig settings) Writes the given statements to the givenOutputStream
in the given format.static void
Writes the given statements to the givenWriter
in the given format.static void
write
(Iterable<Statement> model, Writer output, String baseURI, RDFFormat dataFormat, WriterConfig settings) Writes the given statements to the givenWriter
in the given format.static void
Writes the given statements to the givenWriter
in the given format.static void
Writes the given statements to the givenWriter
in the given format.static void
write
(Iterable<Statement> model, RDFHandler writer) Writes the given statements to the givenRDFHandler
.static void
write
(Statement st, OutputStream output, RDFFormat dataFormat) Writes the given statement to the givenOutputStream
in the given format.static void
write
(Statement st, OutputStream output, RDFFormat dataFormat, WriterConfig settings) Writes the given single statement to the givenOutputStream
in the given format.static void
Writes the given single statement to the givenWriter
in the given format.static void
write
(Statement statement, Writer output, RDFFormat dataFormat, WriterConfig settings) Writes the given single statement to the givenWriter
in the given format.static void
write
(Statement statement, RDFHandler writer) Writes the given single statement to the givenRDFHandler
.
-
Constructor Details
-
Rio
public Rio()
-
-
Method Details
-
getParserFormatForMIMEType
Tries to match a MIME type against the list of RDF formats that can be parsed.- Parameters:
mimeType
- A MIME type, e.g. "application/rdf+xml".- Returns:
- An RDFFormat object if a match was found, or
Optional.empty()
otherwise.
-
getParserFormatForFileName
Tries to match the extension of a file name against the list of RDF formats that can be parsed.- Parameters:
fileName
- A file name.- Returns:
- An RDFFormat object if a match was found, or
Optional.empty()
otherwise.
-
getWriterFormatForMIMEType
Tries to match a MIME type against the list of RDF formats that can be written.- Parameters:
mimeType
- A MIME type, e.g. "application/rdf+xml".- Returns:
- An RDFFormat object if a match was found, or
Optional.empty()
otherwise.
-
getWriterFormatForFileName
Tries to match the extension of a file name against the list of RDF formats that can be written.- Parameters:
fileName
- A file name.- Returns:
- An RDFFormat object if a match was found, or
Optional.empty()
otherwise.
-
createParser
Convenience methods for creating RDFParser objects.This method uses the registry returned byRDFParserRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate parser.- Parameters:
format
-- Returns:
- RDF Parser
- Throws:
UnsupportedRDFormatException
- If no parser is available for the specified RDF format.
-
createParser
public static RDFParser createParser(RDFFormat format, ValueFactory valueFactory) throws UnsupportedRDFormatException Convenience methods for creating RDFParser objects that use the specified ValueFactory to create RDF model objects.- Parameters:
format
-valueFactory
-- Returns:
- RDF Parser
- Throws:
UnsupportedRDFormatException
- If no parser is available for the specified RDF format.- See Also:
-
createWriter
public static RDFWriter createWriter(RDFFormat format, OutputStream out) throws UnsupportedRDFormatException Convenience methods for creating RDFWriter objects.This method uses the registry returned byRDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate writer.- Parameters:
format
-out
-- Returns:
- RDF Writer
- Throws:
UnsupportedRDFormatException
- If no writer is available for the specified RDF format.
-
createWriter
public static RDFWriter createWriter(RDFFormat format, OutputStream out, String baseURI) throws UnsupportedRDFormatException, URISyntaxException Convenience methods for creating RDFWriter objects.This method uses the registry returned byRDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate writer.- Parameters:
format
-out
-baseURI
-- Returns:
- RDF Writer
- Throws:
UnsupportedRDFormatException
- If no writer is available for the specified RDF format.URISyntaxException
- If the baseURI is invalid
-
createWriter
public static RDFWriter createWriter(RDFFormat format, Writer writer) throws UnsupportedRDFormatException Convenience methods for creating RDFWriter objects.This method uses the registry returned byRDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate writer.- Parameters:
format
-writer
-- Returns:
- RDF Writer
- Throws:
UnsupportedRDFormatException
- If no writer is available for the specified RDF format.
-
createWriter
public static RDFWriter createWriter(RDFFormat format, Writer writer, String baseURI) throws UnsupportedRDFormatException, URISyntaxException Convenience methods for creating RDFWriter objects.This method uses the registry returned byRDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create the appropriate writer.- Parameters:
format
-writer
-baseURI
-- Returns:
- RDF Writer
- Throws:
UnsupportedRDFormatException
- If no writer is available for the specified RDF format.URISyntaxException
- If the baseURI is invalid
-
parse
public static Model parse(InputStream in, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.- Parameters:
in
- An InputStream from which RDF data can be read.dataFormat
- The serialization format of the data.contexts
- The contexts to add the data to. If one or more contexts are supplied the method ignores contextual information in the actual data. If no contexts are supplied the contextual information in the input stream is used, if no context information is available the data is added without any context.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the input stream.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.- Since:
- 3.5.0
-
parse
public static Model parse(InputStream in, RDFFormat dataFormat, ParserConfig settings, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.- Parameters:
in
- An InputStream from which RDF data can be read.dataFormat
- The serialization format of the data.settings
- TheParserConfig
containing settings for configuring the parser.contexts
- The contexts to add the data to. If one or more contexts are supplied the method ignores contextual information in the actual data. If no contexts are supplied the contextual information in the input stream is used, if no context information is available the data is added without any context.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the input stream.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.- Since:
- 4.0.0
-
parse
public static Model parse(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.- Parameters:
in
- An InputStream from which RDF data can be read.baseURI
- The base URI to resolve any relative URIs that are in the data against. May benull
.dataFormat
- The serialization format of the data.contexts
- The contexts to add the data to. If one or more contexts are supplied the method ignores contextual information in the actual data. If no contexts are supplied the contextual information in the input stream is used, if no context information is available the data is added without any context.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the input stream.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.
-
parse
public static Model parse(InputStream in, String baseURI, RDFFormat dataFormat, ParserConfig settings, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.- Parameters:
in
- An InputStream from which RDF data can be read.baseURI
- The base URI to resolve any relative URIs that are in the data against. May benull
.dataFormat
- The serialization format of the data.settings
- TheParserConfig
containing settings for configuring the parser.contexts
- The contexts to add the data to. If one or more contexts are supplied the method ignores contextual information in the actual data. If no contexts are supplied the contextual information in the input stream is used, if no context information is available the data is added without any context.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the input stream.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.- Since:
- 4.0.0
-
parse
public static Model parse(InputStream in, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.- Parameters:
in
- An InputStream from which RDF data can be read.baseURI
- The base URI to resolve any relative URIs that are in the data against. May benull
.dataFormat
- The serialization format of the data.settings
- TheParserConfig
containing settings for configuring the parser.valueFactory
- TheValueFactory
used by the parser to create statements.errors
- TheParseErrorListener
used by the parser to signal errors, including errors that do not generate anRDFParseException
.contexts
- The contexts to add the data to. If one or more contexts are supplied the method ignores contextual information in the actual data. If no contexts are supplied the contextual information in the input stream is used, if no context information is available the data is added without any context.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the input stream.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.
-
parse
public static Model parse(InputStream in, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, ModelFactory modelFactory, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from anInputStream
to aModel
, optionally to one or more named contexts.- Parameters:
in
- An InputStream from which RDF data can be read.baseURI
- The base URI to resolve any relative URIs that are in the data against. May benull
.dataFormat
- The serialization format of the data.settings
- TheParserConfig
containing settings for configuring the parser.valueFactory
- TheValueFactory
used by the parser to create statements.errors
- TheParseErrorListener
used by the parser to signal errors, including errors that do not generate anRDFParseException
.modelFactory
- the ModelFactory used to instantiate the model that gets returned.contexts
- The contexts to add the data to. If one or more contexts are supplied the method ignores contextual information in the actual data. If no contexts are supplied the contextual information in the input stream is used, if no context information is available the data is added without any context.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the input stream.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.
-
parse
public static Model parse(Reader reader, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from aReader
to aModel
, optionally to one or more named contexts. Note: using a Reader to upload byte-based data means that you have to be careful not to destroy the data's character encoding by enforcing a default character encoding upon the bytes. If possible, adding such data using an InputStream is to be preferred.- Parameters:
reader
- A Reader from which RDF data can be read.dataFormat
- The serialization format of the data.contexts
- The contexts to add the data to. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the reader.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.- Since:
- 3.5.0
-
parse
public static Model parse(Reader reader, RDFFormat dataFormat, ParserConfig settings, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from aReader
to aModel
, optionally to one or more named contexts. Note: using a Reader to upload byte-based data means that you have to be careful not to destroy the data's character encoding by enforcing a default character encoding upon the bytes. If possible, adding such data using an InputStream is to be preferred.- Parameters:
reader
- A Reader from which RDF data can be read.dataFormat
- The serialization format of the data.settings
- TheParserConfig
containing settings for configuring the parser.contexts
- The contexts to add the data to. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the reader.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.- Since:
- 4.0.0
-
parse
public static Model parse(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from aReader
to aModel
, optionally to one or more named contexts. Note: using a Reader to upload byte-based data means that you have to be careful not to destroy the data's character encoding by enforcing a default character encoding upon the bytes. If possible, adding such data using an InputStream is to be preferred.- Parameters:
reader
- A Reader from which RDF data can be read.baseURI
- The base URI to resolve any relative URIs that are in the data against. May benull
.dataFormat
- The serialization format of the data.contexts
- The contexts to add the data to. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the reader.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.
-
parse
public static Model parse(Reader reader, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from aReader
to aModel
, optionally to one or more named contexts. Note: using a Reader to upload byte-based data means that you have to be careful not to destroy the data's character encoding by enforcing a default character encoding upon the bytes. If possible, adding such data using an InputStream is to be preferred.- Parameters:
reader
- A Reader from which RDF data can be read.baseURI
- The base URI to resolve any relative URIs that are in the data against. May benull
.dataFormat
- The serialization format of the data.settings
- TheParserConfig
containing settings for configuring the parser.valueFactory
- TheValueFactory
used by the parser to create statements.errors
- TheParseErrorListener
used by the parser to signal errors, including errors that do not generate anRDFParseException
.contexts
- The contexts to add the data to. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the reader.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.
-
parse
public static Model parse(Reader reader, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, ModelFactory modelFactory, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException Adds RDF data from aReader
to aModel
, optionally to one or more named contexts. Note: using a Reader to upload byte-based data means that you have to be careful not to destroy the data's character encoding by enforcing a default character encoding upon the bytes. If possible, adding such data using an InputStream is to be preferred.- Parameters:
reader
- A Reader from which RDF data can be read.baseURI
- The base URI to resolve any relative URIs that are in the data against. May benull
.dataFormat
- The serialization format of the data.settings
- TheParserConfig
containing settings for configuring the parser.valueFactory
- TheValueFactory
used by the parser to create statements.errors
- TheParseErrorListener
used by the parser to signal errors, including errors that do not generate anRDFParseException
.modelFactory
- the ModelFactory used to instantiate the model that gets returned.contexts
- The contexts to add the data to. If one or more contexts are specified the data is added to these contexts, ignoring any context information in the data itself.- Returns:
- A
Model
containing the parsed statements. - Throws:
IOException
- If an I/O error occurred while reading from the reader.UnsupportedRDFormatException
- If noRDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.
-
write
public static void write(Iterable<Statement> model, OutputStream output, RDFFormat dataFormat) throws RDFHandlerException Writes the given statements to the givenOutputStream
in the given format.If the collection is a
Model
, its namespaces will also be written.- Parameters:
model
- A collection of statements, such as aModel
, to be written.output
- TheOutputStream
to write the statements to.dataFormat
- TheRDFFormat
to use when writing the statements.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statements.UnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Iterable<Statement> model, OutputStream output, String baseURI, RDFFormat dataFormat) throws RDFHandlerException, UnsupportedRDFormatException, URISyntaxException Writes the given statements to the givenOutputStream
in the given format.If the collection is a
Model
, its namespaces will also be written.- Parameters:
model
- A collection of statements, such as aModel
, to be written.output
- TheOutputStream
to write the statements to.baseURI
- The base URI to relativize IRIs against.dataFormat
- TheRDFFormat
to use when writing the statements.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statements.URISyntaxException
- If the baseURI is invalidUnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Iterable<Statement> model, Writer output, RDFFormat dataFormat) throws RDFHandlerException Writes the given statements to the givenWriter
in the given format.If the collection is a
Model
, its namespaces will also be written.- Parameters:
model
- A collection of statements, such as aModel
, to be written.output
- TheWriter
to write the statements to.dataFormat
- TheRDFFormat
to use when writing the statements.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statements.UnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Iterable<Statement> model, Writer output, String baseURI, RDFFormat dataFormat) throws RDFHandlerException, UnsupportedRDFormatException, URISyntaxException Writes the given statements to the givenWriter
in the given format.If the collection is a
Model
, its namespaces will also be written.- Parameters:
model
- A collection of statements, such as aModel
, to be written.output
- TheWriter
to write the statements to.baseURI
- The base URI to relativize IRIs against.dataFormat
- TheRDFFormat
to use when writing the statements.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statements.URISyntaxException
- If the baseURI is invalidUnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Iterable<Statement> model, OutputStream output, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException Writes the given statements to the givenOutputStream
in the given format.If the collection is a
Model
, its namespaces will also be written.- Parameters:
model
- A collection of statements, such as aModel
, to be written.output
- TheOutputStream
to write the statements to.dataFormat
- TheRDFFormat
to use when writing the statements.settings
- TheWriterConfig
containing settings for configuring the writer.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statements.UnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Iterable<Statement> model, OutputStream output, String baseURI, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException, UnsupportedRDFormatException, URISyntaxException Writes the given statements to the givenOutputStream
in the given format.If the collection is a
Model
, its namespaces will also be written.- Parameters:
model
- A collection of statements, such as aModel
, to be written.output
- TheOutputStream
to write the statements to.baseURI
- The base URI to relativize IRIs against.dataFormat
- TheRDFFormat
to use when writing the statements.settings
- TheWriterConfig
containing settings for configuring the writer.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statements.URISyntaxException
- If the baseURI is invalidUnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Iterable<Statement> model, Writer output, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException Writes the given statements to the givenWriter
in the given format.If the collection is a
Model
, its namespaces will also be written.- Parameters:
model
- A collection of statements, such as aModel
, to be written.output
- TheWriter
to write the statements to.dataFormat
- TheRDFFormat
to use when writing the statements.settings
- TheWriterConfig
containing settings for configuring the writer.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statements.UnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Iterable<Statement> model, Writer output, String baseURI, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException, UnsupportedRDFormatException, URISyntaxException Writes the given statements to the givenWriter
in the given format.If the collection is a
Model
, its namespaces will also be written.- Parameters:
model
- A collection of statements, such as aModel
, to be written.output
- TheWriter
to write the statements to.baseURI
- The base URI to relativize IRIs against.dataFormat
- TheRDFFormat
to use when writing the statements.settings
- TheWriterConfig
containing settings for configuring the writer.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statements.URISyntaxException
- If the baseURI is invalidUnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
Writes the given statements to the givenRDFHandler
.If the collection is a
Model
, its namespaces will also be written.- Parameters:
model
- A collection of statements, such as aModel
, to be written.writer
-- Throws:
RDFHandlerException
- Thrown if there is an error writing the statements.
-
write
public static void write(Statement st, OutputStream output, RDFFormat dataFormat) throws RDFHandlerException Writes the given statement to the givenOutputStream
in the given format.- Parameters:
st
- The statement to be written.output
- TheOutputStream
to write the statement to.dataFormat
- TheRDFFormat
to use when writing the statement.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statement.UnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Statement st, OutputStream output, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException Writes the given single statement to the givenOutputStream
in the given format.- Parameters:
st
- The statement to be written.output
- TheOutputStream
to write the statement to.dataFormat
- TheRDFFormat
to use when writing the statement.settings
- TheWriterConfig
containing setting for configuring the writer.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statement.UnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Statement statement, Writer output, RDFFormat dataFormat) throws RDFHandlerException Writes the given single statement to the givenWriter
in the given format.- Parameters:
statement
- A statement to be written.output
- TheWriter
to write the statement to.dataFormat
- TheRDFFormat
to use when writing the statement.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statement.UnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
public static void write(Statement statement, Writer output, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException Writes the given single statement to the givenWriter
in the given format.- Parameters:
statement
- A statement to be written.output
- TheWriter
to write the statement to.dataFormat
- TheRDFFormat
to use when writing the statement.settings
- TheWriterConfig
containing settings for configuring the writer.- Throws:
RDFHandlerException
- Thrown if there is an error writing the statement.UnsupportedRDFormatException
- If noRDFWriter
is available for the specified RDF format.
-
write
Writes the given single statement to the givenRDFHandler
.- Parameters:
statement
- A statement, to be written.writer
-- Throws:
RDFHandlerException
- Thrown if there is an error writing the statement.
-
main
public static void main(String[] args) throws IOException, RDFParseException, RDFHandlerException, UnsupportedRDFormatException -
unsupportedFormat
Helper method to use to create a lambda forOptional.orElseThrow(Supplier)
to indicate a format is unsupported.- Parameters:
unsupportedFormat
- The format that was not found.- Returns:
- A lambda that can be used to generate an exception if the format is not found.
-
unsupportedFormat
Helper method to use to create a lambda forOptional.orElseThrow(Supplier)
to indicate a format is unsupported.- Parameters:
unsupportedFormat
- The format that was not found.- Returns:
- A lambda that can be used to generate an exception if the format is not found.
-