edu.stanford.smi.protegex.owl.model.triplestore
Interface TripleWriter

All Known Implementing Classes:
DelegatingTripleWriter, JenaMemoryTripleWriter

public interface TripleWriter

An interface for objects that can write Triples into a file or other stream. This can be used as a uniform way of generating OWL files.

The usual contract to use TripleWriters is

  1. init()
  2. writePrefix()*
  3. addImport()*
  4. write()*
  5. close()

Author:
Holger Knublauch

Method Summary
 void addImport(String uri)
          Adds an owl:imports statement to the default ontology in this writer.
 void close()
          Tells the writer that we're finished.
 void init(String baseURI)
          Initializes this writer to work with a given base URI.
 void write(RDFResource resource, RDFProperty property, Object object)
          Writes a given Triples into this writer.
 void writePrefix(String prefix, String namespace)
          Writes a prefix declaration into this writer.
 

Method Detail

addImport

public void addImport(String uri)
Adds an owl:imports statement to the default ontology in this writer. This is a convenience method because the same can typically be achieved by adding a corresponding triple.

Parameters:
uri - the URI to add

close

public void close()
           throws Exception
Tells the writer that we're finished. This method should be called at the end of a writing process. After this method has been called, no other calls to this object are permitted.

Throws:
Exception

init

public void init(String baseURI)
Initializes this writer to work with a given base URI. This URI will also be the URI of the default ontology in this file, and future calls of addImport will add to this ontology.

Parameters:
baseURI - the base URI, such as http://www.a.com/ontology.owl

write

public void write(RDFResource resource,
                  RDFProperty property,
                  Object object)
           throws Exception
Writes a given Triples into this writer.

Throws:
Exception

writePrefix

public void writePrefix(String prefix,
                        String namespace)
                 throws Exception
Writes a prefix declaration into this writer. Since namespace declarations are typically written to the beginning of a file, implementations of this method may require that any calls to this method are done before the first triple is written out.

Parameters:
prefix - the prefix to define ("" for the default namespace)
namespace - the namespace to assign to the prefix
Throws:
Exception