com.clarkparsia.stardog.api
Interface IO


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(org.openrdf.model.Resource) context} and/or format(org.openrdf.rio.RDFFormat) format, you can repeatedly use the object to read in RDF from a 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 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);
   }

 

Since:
0.3
Version:
0.7
Author:
Michael Grove
See Also:
Adder, Remover

Method Summary
 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(File 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 stream(InputStream theStream)
          Read RDF data from the provided InputStream.
 

Method Detail

format

IO format(RDFFormat theFormat)
          throws StardogException
Specify that subsequent IO operations with this class will be parsed using this RDF format.

Parameters:
theFormat - the RDF format to use
Returns:
this IO
Throws:
StardogException - if there is an error

stream

IO stream(InputStream theStream)
          throws StardogException

Read RDF data from the provided InputStream. You must have specified a format(org.openrdf.rio.RDFFormat) before reading the RDF data.

The stream is closed after the content is parsed.

Parameters:
theStream - the stream
Returns:
this IO
Throws:
StardogException - if there is an error
See Also:
format(org.openrdf.rio.RDFFormat)

file

IO file(File theFile)
        throws StardogException

Load RDF data from this file. You must have specified a format(org.openrdf.rio.RDFFormat) format} before reading the RDF data.

Parameters:
theFile - the file to load from
Returns:
this IO
Throws:
StardogException - if there was an error
See Also:
format(org.openrdf.rio.RDFFormat)

context

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.

Parameters:
theContext - the context for the statements
Returns:
this IO
Throws:
StardogException - if there was an error setting the context


Copyright © 2010-2013 Clark & Parsia. All Rights Reserved.