org.openrdf.rio.ntriples
Class NTriplesWriter

java.lang.Object
  extended byorg.openrdf.rio.ntriples.NTriplesWriter
All Implemented Interfaces:
RdfDocumentWriter

public class NTriplesWriter
extends Object
implements RdfDocumentWriter

An implementation of the RdfDocumentWriter interface that writes RDF documents in N-Triples format. The N-Triples format is defined in this section of the RDF Test Cases document.


Constructor Summary
NTriplesWriter(OutputStream out)
          Creates a new NTriplesWriter that will write to the supplied OutputStream.
NTriplesWriter(Writer out)
          Creates a new NTriplesWriter that will write to the supplied Writer.
 
Method Summary
 void endDocument()
          Ends the document writing.
 void setNamespace(String prefix, String name)
          Sets a mapping from a namespace prefix to a namespace name.
 void startDocument()
          Starts the document writing.
 void writeComment(String comment)
          Writes a comment to the document.
 void writeStatement(Resource subj, URI pred, Value obj)
          Writes a statement to the document.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NTriplesWriter

public NTriplesWriter(OutputStream out)
Creates a new NTriplesWriter that will write to the supplied OutputStream.

Parameters:
out - The OutputStream to write the N-Triples document to.

NTriplesWriter

public NTriplesWriter(Writer out)
Creates a new NTriplesWriter that will write to the supplied Writer.

Parameters:
out - The Writer to write the N-Triples document to.
Method Detail

setNamespace

public void setNamespace(String prefix,
                         String name)
Description copied from interface: RdfDocumentWriter
Sets a mapping from a namespace prefix to a namespace name. Some implementations of this interface may require that namespace are set before the document writing starts (i.e. before startDocument() is called). Note that a mapping can only be defined once for a given namespace name. The RdfDocumentWriter will ignore an attempt to define a mapping for a namespace it already has a mapping for.

Specified by:
setNamespace in interface RdfDocumentWriter

startDocument

public void startDocument()
                   throws IOException
Description copied from interface: RdfDocumentWriter
Starts the document writing.

Specified by:
startDocument in interface RdfDocumentWriter
Throws:
IOException

endDocument

public void endDocument()
                 throws IOException
Description copied from interface: RdfDocumentWriter
Ends the document writing.

Specified by:
endDocument in interface RdfDocumentWriter
Throws:
IOException

writeStatement

public void writeStatement(Resource subj,
                           URI pred,
                           Value obj)
                    throws IOException
Description copied from interface: RdfDocumentWriter
Writes a statement to the document. The startDocument() method should have been called before.

Specified by:
writeStatement in interface RdfDocumentWriter
Throws:
IOException

writeComment

public void writeComment(String comment)
                  throws IOException
Description copied from interface: RdfDocumentWriter
Writes a comment to the document. An implementation may ignore these calls if the format doesn't support comments.

Specified by:
writeComment in interface RdfDocumentWriter
Throws:
IOException


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.