Class TurtleWriter

    • Field Detail

      • mWriter

        protected final com.stardog.common.io.block.BlockWriter mWriter
      • mOptions

        protected final Options mOptions
      • mNamespaces

        protected final java.util.Map<java.lang.String,​java.lang.String> mNamespaces
      • mStarted

        protected boolean mStarted
      • mStmtClosed

        protected boolean mStmtClosed
      • mLastWrittenSubject

        protected Resource mLastWrittenSubject
      • mLastWrittenPredicate

        protected IRI mLastWrittenPredicate
      • mBlockSpec

        protected com.stardog.common.io.block.BlockSpec mBlockSpec
    • Constructor Detail

      • TurtleWriter

        public TurtleWriter​(java.io.OutputStream theWriter,
                            Options theOptions)
    • Method Detail

      • comment

        public void comment​(@Nonnull
                            java.lang.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
      • writeCommentLine

        protected void writeCommentLine​(@Nonnull
                                        java.lang.String theLine)
      • start

        public void start()
        Signals that the RDF writing process is starting.
        Specified by:
        start in interface RDFHandler
        Specified by:
        start in interface RDFWriter
      • 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
      • namespace

        public void namespace​(@Nonnull
                              java.lang.String thePrefix,
                              @Nonnull
                              java.lang.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
      • closePreviousStatement

        protected void closePreviousStatement()
      • writeNamespace

        protected void writeNamespace​(@Nonnull
                                      java.lang.String thePrefix,
                                      @Nonnull
                                      java.lang.String theIRI)
      • writePredicate

        protected void writePredicate​(@Nonnull
                                      IRI predicate)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeResource

        protected void writeResource​(@Nonnull
                                     Resource res)
                              throws java.io.IOException
        Writes a Resource, optionally shortening it if it is an IRI and has a namespace definition that is suitable for use in this context for shortening or a BNode that has been confirmed to be able to be shortened in this context.
        Parameters:
        res - The Resource to write.
        Throws:
        java.io.IOException - if the write operation to the underlying stream fails
      • writeEmbeddedTriple

        protected void writeEmbeddedTriple​(@Nonnull
                                           Statement statement)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • writeValue

        protected void writeValue​(@Nonnull
                                  Value theValue)
                           throws java.io.IOException
        Writes a value, optionally shortening it if it is an IRI and has a namespace definition that is suitable for use in this context for shortening or a BNode that has been confirmed to be able to be shortened in this context.
        Parameters:
        theValue - The Value to write.
        Throws:
        java.io.IOException - if the write operation to the underlying stream fails
      • writeIRI

        protected void writeIRI​(@Nonnull
                                IRI theIRI)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBNode

        protected void writeBNode​(@Nonnull
                                  BNode bNode)
                           throws java.io.IOException
        Parameters:
        bNode - The BNode to write.
        Throws:
        java.io.IOException - if the write operation to the underlying stream fails
      • writeLiteral

        protected void writeLiteral​(@Nonnull
                                    Literal theLiteral)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • format

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