Interface RDFWriter

All Superinterfaces:
RDFHandler
All Known Implementing Classes:
BinaryRDFWriter, ForwardingRDFWriter, JSONLDWriter, NQuadsWriter, NTWriter, PrettyTurtleWriter, RDFJSONWriter, RDFXMLPrettyWriter, RDFXMLWriter, StreamingJSONLDWriter, TrigWriter, TurtleWriter

public interface RDFWriter extends RDFHandler

A writer to serialize RDF statements in a particular RDF format.

Since:
1.0
Version:
1.0
Author:
Michael Grove
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    comment(String theComment)
    Write a comment to the output.
    void
    end()
    Signals the writing process is completed.
    The format this writer will serialize output in.
    void
    handle(Statement theStmt)
    Write the given Statement
    void
    namespace(String thePrefix, String theIRI)
    Provide a namespace to the writer.
    void
    Signals that the RDF writing process is starting.
  • Method Details

    • start

      void start()
      Signals that the RDF writing process is starting.
      Specified by:
      start in interface RDFHandler
    • handle

      void handle(@Nonnull Statement theStmt)
      Write the given Statement
      Specified by:
      handle in interface RDFHandler
      Parameters:
      theStmt - the statement to write
      Implementation Notes:
      It is generally assumed that output has to be started prior to writing Statements, but it is not required as not all syntaxes will have a preamble requirement, such as the opening `rdf:RDF` tag in RDF/XML. It should not be possible to continue writing statements after the writing processes has ended
    • namespace

      void namespace(@Nonnull String thePrefix, @Nonnull String theIRI)
      Provide a namespace to the writer. This method can be called before writing has started, in which case, the namespace bindings are buffered and written when appropriate after writing has begun.
      Specified by:
      namespace in interface RDFHandler
      Parameters:
      thePrefix - the namespace prefix
      theIRI - the associated IRI
      Implementation Notes:
      It is assumed that the namespaces will be used to shorten output via QNames for syntaxes which support them.
    • comment

      void comment(@Nonnull String theComment)
      Write a comment to the output. Writing need not be started at this point; comments can be written prior to any actual serialized RDF
      Parameters:
      theComment - the comment to write
    • end

      void end()
      Signals the writing process is completed. The underlying InputStream is *not* closed, but the caller should not call additional methods on this writer as that will normally yield syntax errors in the output.
      Specified by:
      end in interface RDFHandler
    • format

      @Nonnull RDFFormat format()
      The format this writer will serialize output in.
      Returns:
      the format