Constructor and Description |
---|
Rio() |
Modifier and Type | Method and Description |
---|---|
static RDFParser |
createParser(RDFFormat format)
Convenience methods for creating RDFParser objects.This method uses the registry returned by
RDFParserRegistry.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 by
RDFWriterRegistry.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 by
RDFWriterRegistry.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 by
RDFWriterRegistry.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 by
RDFWriterRegistry.getInstance() to get a factory for the specified format and uses this factory to create
the appropriate writer. |
static Optional<RDFFormat> |
getParserFormatForFileName(String fileName)
Tries to match the extension of a file name against the list of RDF formats that can be parsed.
|
static Optional<RDFFormat> |
getParserFormatForMIMEType(String mimeType)
Tries to match a MIME type against the list of RDF formats that can be parsed.
|
static Optional<RDFFormat> |
getWriterFormatForFileName(String fileName)
Tries to match the extension of a file name against the list of RDF formats that can be written.
|
static Optional<RDFFormat> |
getWriterFormatForMIMEType(String mimeType)
Tries to match a MIME type against the list of RDF formats that can be written.
|
static void |
main(String[] args) |
static Model |
parse(InputStream in,
String baseURI,
RDFFormat dataFormat,
ParserConfig settings,
ValueFactory valueFactory,
ParseErrorListener errors,
ModelFactory modelFactory,
Resource... contexts)
Adds RDF data from an
InputStream to a Model , 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 an
InputStream to a Model , optionally to one or more named contexts. |
static Model |
parse(InputStream in,
String baseURI,
RDFFormat dataFormat,
Resource... contexts)
Adds RDF data from an
InputStream to a Model , optionally to one or more named contexts. |
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 |
parse(Reader reader,
String baseURI,
RDFFormat dataFormat,
Resource... contexts)
|
static java.util.function.Supplier<UnsupportedRDFormatException> |
unsupportedFormat(RDFFormat unsupportedFormat)
Helper method to use to create a lambda for
Optional.orElseThrow(Supplier) to indicate a format is
unsupported. |
static java.util.function.Supplier<UnsupportedRDFormatException> |
unsupportedFormat(String unsupportedFormat)
Helper method to use to create a lambda for
Optional.orElseThrow(Supplier) to indicate a format is
unsupported. |
static void |
write(Iterable<Statement> model,
OutputStream output,
RDFFormat dataFormat)
Writes the given statements to the given
OutputStream in the given format. |
static void |
write(Iterable<Statement> model,
OutputStream output,
RDFFormat dataFormat,
WriterConfig settings)
Writes the given statements to the given
OutputStream in the given format. |
static void |
write(Iterable<Statement> model,
OutputStream output,
String baseURI,
RDFFormat dataFormat)
Writes the given statements to the given
OutputStream in the given format. |
static void |
write(Iterable<Statement> model,
OutputStream output,
String baseURI,
RDFFormat dataFormat,
WriterConfig settings)
Writes the given statements to the given
OutputStream in the given format. |
static void |
write(Iterable<Statement> model,
RDFHandler writer)
Writes the given statements to the given
RDFHandler . |
static void |
write(Iterable<Statement> model,
Writer output,
RDFFormat dataFormat)
Writes the given statements to the given
Writer in the given format. |
static void |
write(Iterable<Statement> model,
Writer output,
RDFFormat dataFormat,
WriterConfig settings)
Writes the given statements to the given
Writer in the given format. |
static void |
write(Iterable<Statement> model,
Writer output,
String baseURI,
RDFFormat dataFormat)
Writes the given statements to the given
Writer in the given format. |
static void |
write(Iterable<Statement> model,
Writer output,
String baseURI,
RDFFormat dataFormat,
WriterConfig settings)
Writes the given statements to the given
Writer in the given format. |
static void |
write(Statement st,
OutputStream output,
RDFFormat dataFormat)
Writes the given statement to the given
OutputStream in the given format. |
static void |
write(Statement st,
OutputStream output,
RDFFormat dataFormat,
WriterConfig settings)
Writes the given single statement to the given
OutputStream in the given format. |
static void |
write(Statement statement,
RDFHandler writer)
Writes the given single statement to the given
RDFHandler . |
static void |
write(Statement statement,
Writer output,
RDFFormat dataFormat)
Writes the given single statement to the given
Writer in the given format. |
static void |
write(Statement statement,
Writer output,
RDFFormat dataFormat,
WriterConfig settings)
Writes the given single statement to the given
Writer in the given format. |
public static Optional<RDFFormat> getParserFormatForMIMEType(String mimeType)
mimeType
- A MIME type, e.g. "application/rdf+xml".Optional.empty()
otherwise.public static Optional<RDFFormat> getParserFormatForFileName(String fileName)
fileName
- A file name.Optional.empty()
otherwise.public static Optional<RDFFormat> getWriterFormatForMIMEType(String mimeType)
mimeType
- A MIME type, e.g. "application/rdf+xml".Optional.empty()
otherwise.public static Optional<RDFFormat> getWriterFormatForFileName(String fileName)
fileName
- A file name.Optional.empty()
otherwise.public static RDFParser createParser(RDFFormat format) throws UnsupportedRDFormatException
RDFParserRegistry.getInstance()
to get a factory for the specified format and uses this factory to create
the appropriate parser.format
- UnsupportedRDFormatException
- If no parser is available for the specified RDF format.public static RDFParser createParser(RDFFormat format, ValueFactory valueFactory) throws UnsupportedRDFormatException
format
- valueFactory
- UnsupportedRDFormatException
- If no parser is available for the specified RDF format.createParser(RDFFormat)
,
RDFParser.setValueFactory(ValueFactory)
public static RDFWriter createWriter(RDFFormat format, OutputStream out) throws UnsupportedRDFormatException
RDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create
the appropriate writer.format
- out
- UnsupportedRDFormatException
- If no writer is available for the specified RDF format.public static RDFWriter createWriter(RDFFormat format, OutputStream out, String baseURI) throws UnsupportedRDFormatException, URISyntaxException
RDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create
the appropriate writer.format
- out
- baseURI
- UnsupportedRDFormatException
- If no writer is available for the specified RDF format.URISyntaxException
- If the baseURI is invalidpublic static RDFWriter createWriter(RDFFormat format, Writer writer) throws UnsupportedRDFormatException
RDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create
the appropriate writer.format
- writer
- UnsupportedRDFormatException
- If no writer is available for the specified RDF format.public static RDFWriter createWriter(RDFFormat format, Writer writer, String baseURI) throws UnsupportedRDFormatException, URISyntaxException
RDFWriterRegistry.getInstance()
to get a factory for the specified format and uses this factory to create
the appropriate writer.format
- writer
- baseURI
- UnsupportedRDFormatException
- If no writer is available for the specified RDF format.URISyntaxException
- If the baseURI is invalidpublic static Model parse(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException
InputStream
to a Model
, optionally to one or more named contexts.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.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.Model
containing the parsed statements.IOException
- If an I/O error occurred while reading from the input stream.UnsupportedRDFormatException
- If no RDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.public static Model parse(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException
Reader
to a Model
, 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.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.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.Model
containing the parsed statements.IOException
- If an I/O error occurred while reading from the reader.UnsupportedRDFormatException
- If no RDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.public static Model parse(InputStream in, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException
InputStream
to a Model
, optionally to one or more named contexts.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.dataFormat
- The serialization format of the data.settings
- The ParserConfig
containing settings for configuring the parser.valueFactory
- The ValueFactory
used by the parser to create statements.errors
- The ParseErrorListener
used by the parser to signal errors, including errors that do
not generate an RDFParseException
.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.Model
containing the parsed statements.IOException
- If an I/O error occurred while reading from the input stream.UnsupportedRDFormatException
- If no RDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.public static Model parse(InputStream in, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, ModelFactory modelFactory, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException
InputStream
to a Model
, optionally to one or more named contexts.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.dataFormat
- The serialization format of the data.settings
- The ParserConfig
containing settings for configuring the parser.valueFactory
- The ValueFactory
used by the parser to create statements.errors
- The ParseErrorListener
used by the parser to signal errors, including errors that do
not generate an RDFParseException
.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.Model
containing the parsed statements.IOException
- If an I/O error occurred while reading from the input stream.UnsupportedRDFormatException
- If no RDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.public static Model parse(Reader reader, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException
Reader
to a Model
, 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.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.dataFormat
- The serialization format of the data.settings
- The ParserConfig
containing settings for configuring the parser.valueFactory
- The ValueFactory
used by the parser to create statements.errors
- The ParseErrorListener
used by the parser to signal errors, including errors that do
not generate an RDFParseException
.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.Model
containing the parsed statements.IOException
- If an I/O error occurred while reading from the reader.UnsupportedRDFormatException
- If no RDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.public static Model parse(Reader reader, String baseURI, RDFFormat dataFormat, ParserConfig settings, ValueFactory valueFactory, ParseErrorListener errors, ModelFactory modelFactory, Resource... contexts) throws IOException, RDFParseException, UnsupportedRDFormatException
Reader
to a Model
, 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.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.dataFormat
- The serialization format of the data.settings
- The ParserConfig
containing settings for configuring the parser.valueFactory
- The ValueFactory
used by the parser to create statements.errors
- The ParseErrorListener
used by the parser to signal errors, including errors that do
not generate an RDFParseException
.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.Model
containing the parsed statements.IOException
- If an I/O error occurred while reading from the reader.UnsupportedRDFormatException
- If no RDFParser
is available for the specified RDF format.RDFParseException
- If an error was found while parsing the RDF data.public static void write(Iterable<Statement> model, OutputStream output, RDFFormat dataFormat) throws RDFHandlerException
OutputStream
in the given format.
If the collection is a Model
, its namespaces will also be written.
model
- A collection of statements, such as a Model
, to be written.output
- The OutputStream
to write the statements to.dataFormat
- The RDFFormat
to use when writing the statements.RDFHandlerException
- Thrown if there is an error writing the statements.UnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Iterable<Statement> model, OutputStream output, String baseURI, RDFFormat dataFormat) throws RDFHandlerException, UnsupportedRDFormatException, URISyntaxException
OutputStream
in the given format.
If the collection is a Model
, its namespaces will also be written.
model
- A collection of statements, such as a Model
, to be written.output
- The OutputStream
to write the statements to.baseURI
- The base URI to relativize IRIs against.dataFormat
- The RDFFormat
to use when writing the statements.RDFHandlerException
- Thrown if there is an error writing the statements.URISyntaxException
- If the baseURI is invalidUnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Iterable<Statement> model, Writer output, RDFFormat dataFormat) throws RDFHandlerException
Writer
in the given format.
If the collection is a Model
, its namespaces will also be written.
model
- A collection of statements, such as a Model
, to be written.output
- The Writer
to write the statements to.dataFormat
- The RDFFormat
to use when writing the statements.RDFHandlerException
- Thrown if there is an error writing the statements.UnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Iterable<Statement> model, Writer output, String baseURI, RDFFormat dataFormat) throws RDFHandlerException, UnsupportedRDFormatException, URISyntaxException
Writer
in the given format.
If the collection is a Model
, its namespaces will also be written.
model
- A collection of statements, such as a Model
, to be written.output
- The Writer
to write the statements to.baseURI
- The base URI to relativize IRIs against.dataFormat
- The RDFFormat
to use when writing the statements.RDFHandlerException
- Thrown if there is an error writing the statements.URISyntaxException
- If the baseURI is invalidUnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Iterable<Statement> model, OutputStream output, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException
OutputStream
in the given format.
If the collection is a Model
, its namespaces will also be written.
model
- A collection of statements, such as a Model
, to be written.output
- The OutputStream
to write the statements to.dataFormat
- The RDFFormat
to use when writing the statements.settings
- The WriterConfig
containing settings for configuring the writer.RDFHandlerException
- Thrown if there is an error writing the statements.UnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Iterable<Statement> model, OutputStream output, String baseURI, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException, UnsupportedRDFormatException, URISyntaxException
OutputStream
in the given format.
If the collection is a Model
, its namespaces will also be written.
model
- A collection of statements, such as a Model
, to be written.output
- The OutputStream
to write the statements to.baseURI
- The base URI to relativize IRIs against.dataFormat
- The RDFFormat
to use when writing the statements.settings
- The WriterConfig
containing settings for configuring the writer.RDFHandlerException
- Thrown if there is an error writing the statements.URISyntaxException
- If the baseURI is invalidUnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Iterable<Statement> model, Writer output, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException
Writer
in the given format.
If the collection is a Model
, its namespaces will also be written.
model
- A collection of statements, such as a Model
, to be written.output
- The Writer
to write the statements to.dataFormat
- The RDFFormat
to use when writing the statements.settings
- The WriterConfig
containing settings for configuring the writer.RDFHandlerException
- Thrown if there is an error writing the statements.UnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Iterable<Statement> model, Writer output, String baseURI, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException, UnsupportedRDFormatException, URISyntaxException
Writer
in the given format.
If the collection is a Model
, its namespaces will also be written.
model
- A collection of statements, such as a Model
, to be written.output
- The Writer
to write the statements to.baseURI
- The base URI to relativize IRIs against.dataFormat
- The RDFFormat
to use when writing the statements.settings
- The WriterConfig
containing settings for configuring the writer.RDFHandlerException
- Thrown if there is an error writing the statements.URISyntaxException
- If the baseURI is invalidUnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Iterable<Statement> model, RDFHandler writer) throws RDFHandlerException
RDFHandler
.
If the collection is a Model
, its namespaces will also be written.
model
- A collection of statements, such as a Model
, to be written.writer
- RDFHandlerException
- Thrown if there is an error writing the statements.public static void write(Statement st, OutputStream output, RDFFormat dataFormat) throws RDFHandlerException
OutputStream
in the given format.
st
- The statement to be written.output
- The OutputStream
to write the statement to.dataFormat
- The RDFFormat
to use when writing the statement.RDFHandlerException
- Thrown if there is an error writing the statement.UnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Statement st, OutputStream output, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException
OutputStream
in the given format.st
- The statement to be written.output
- The OutputStream
to write the statement to.dataFormat
- The RDFFormat
to use when writing the statement.settings
- The WriterConfig
containing setting for configuring the writer.RDFHandlerException
- Thrown if there is an error writing the statement.UnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Statement statement, Writer output, RDFFormat dataFormat) throws RDFHandlerException
Writer
in the given format.
statement
- A statement to be written.output
- The Writer
to write the statement to.dataFormat
- The RDFFormat
to use when writing the statement.RDFHandlerException
- Thrown if there is an error writing the statement.UnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Statement statement, Writer output, RDFFormat dataFormat, WriterConfig settings) throws RDFHandlerException
Writer
in the given format.
statement
- A statement to be written.output
- The Writer
to write the statement to.dataFormat
- The RDFFormat
to use when writing the statement.settings
- The WriterConfig
containing settings for configuring the writer.RDFHandlerException
- Thrown if there is an error writing the statement.UnsupportedRDFormatException
- If no RDFWriter
is available for the specified RDF format.public static void write(Statement statement, RDFHandler writer) throws RDFHandlerException
RDFHandler
.
statement
- A statement, to be written.writer
- RDFHandlerException
- Thrown if there is an error writing the statement.public static void main(String[] args) throws IOException, RDFParseException, RDFHandlerException, UnsupportedRDFormatException
public static java.util.function.Supplier<UnsupportedRDFormatException> unsupportedFormat(RDFFormat unsupportedFormat)
Optional.orElseThrow(Supplier)
to indicate a format is
unsupported.unsupportedFormat
- The format that was not found.public static java.util.function.Supplier<UnsupportedRDFormatException> unsupportedFormat(String unsupportedFormat)
Optional.orElseThrow(Supplier)
to indicate a format is
unsupported.unsupportedFormat
- The format that was not found.Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.