public interface IO
IO interface for reading RDF data from various input sources.
This interface is usually used in conjunction with Adder
or Remover
to specify the RDF to be added/removed from the parent Connection
The IO object is stateful in that once you set the
context(Resource)
context} and/or
format(RDFFormat)
format, you can repeatedly use the object
to read in RDF from a file(Path)
file} or stream
using the same context/format.
Usage
Connection aConn = // obtain connection
aConn.add().io().format(RDFFormat.TURTLE).file(new File("mydata.ttl"));
// reuse the object
URI aContext = Values.uri("urn:context");
IO aIO = aConn.add().io();
aIO.format(RDFFormat.TURTLE)
.context(aCxt);
Collection<File> aFiles = // get file list
for (File aFile : aFiles) {
// this will parse the file using the Turtle parser & put the resulting RDF
// into the previously specified context.
aIO.file(aFile);
}
Modifier and Type | Method and Description |
---|---|
IO |
context(Resource theContext)
Set the context that will be applied to all statements created when the RDF is read
in from the specified IO source.
|
IO |
file(Path theFile)
Load RDF data from this file.
|
IO |
format(RDFFormat theFormat)
Specify that subsequent IO operations with this class will be parsed using this RDF format.
|
IO |
serverSide()
Normally, it is assumed that a
file(Path) file} resides on the same machine
as the client. |
IO |
stream(InputStream theStream)
Read RDF data from the provided
InputStream . |
IO format(RDFFormat theFormat) throws StardogException
theFormat
- the RDF format to useStardogException
- if there is an errorIO stream(InputStream theStream) throws StardogException
Read RDF data from the provided InputStream
. You must have specified a
format(RDFFormat)
before reading the RDF data.
The stream is closed after the content is parsed.
theStream
- the streamStardogException
- if there is an errorformat(RDFFormat)
IO file(Path theFile) throws StardogException
Load RDF data from this file. If no format(RDFFormat)
format}
is specified a format will be guessed based on the file extension. If the path points to
a directory all the files in that directory will be loaded recursively. If no format is
specified then only the files in the directory with a recognized file extension will be
loaded.
theFile
- the file to load fromStardogException
- if there was an errorformat(RDFFormat)
IO context(Resource theContext) throws StardogException
Set the context that will be applied to all statements created when the RDF is read in from the specified IO source. If you are using an RDF format which specifies a context, such as Trig or NQuads, the context on the parsed statements will override any specified context value.
theContext
- the context for the statementsStardogException
- if there was an error setting the contextIO serverSide()
Normally, it is assumed that a file(Path)
file} resides on the same machine
as the client. When this option is enabled, the Connection will assume the file is located
on the server so that only the reference to the file, rather than its contents, needs
to be sent to the server.
Copyright © 2010-2016 Stardog Union. All Rights Reserved.