Class RDFJSONWriter

java.lang.Object
com.stardog.stark.io.rdfjson.RDFJSONWriter
All Implemented Interfaces:
RDFHandler, RDFWriter

public final class RDFJSONWriter extends Object implements RDFWriter

Writer for RDF in RDF/JSON format

Since:
1.0
Version:
1.0
Author:
Peter Ansell, Michael Grove
See Also:
Implementation Notes:
This class buffers the written statements until the end() so it is not suitable for writing large graphs.
  • Constructor Details

    • RDFJSONWriter

      public RDFJSONWriter(@Nonnull OutputStream theStream, @Nonnull Options theOptions)
  • Method Details

    • end

      public 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
      Specified by:
      end in interface RDFWriter
    • comment

      public 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
      Specified by:
      comment in interface RDFWriter
      Parameters:
      theComment - the comment to write
    • namespace

      public 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
      Specified by:
      namespace in interface RDFWriter
      Parameters:
      thePrefix - the namespace prefix
      theIRI - the associated IRI
    • handle

      public void handle(@Nonnull Statement theStmt)
      Write the given Statement
      Specified by:
      handle in interface RDFHandler
      Specified by:
      handle in interface RDFWriter
      Parameters:
      theStmt - the statement to write
    • start

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

      public static String resourceToString(Resource uriOrBnode)
      Returns the correct syntax for a Resource, depending on whether it is a URI or a Blank Node (ie, BNode)
      Parameters:
      uriOrBnode - The resource to serialise to a string
      Returns:
      The string value of the sesame resource
    • format

      @Nonnull public RDFFormat format()
      The format this writer will serialize output in.
      Specified by:
      format in interface RDFWriter
      Returns:
      the format