Class StreamingJSONLDWriter

  • All Implemented Interfaces:
    RDFHandler, RDFWriter

    public class StreamingJSONLDWriter
    extends java.lang.Object
    implements RDFWriter

    Streaming writer for JSON-LD

    Author:
    Evren Sirin
    • Field Detail

      • mWriter

        protected final com.fasterxml.jackson.core.JsonGenerator mWriter
      • mOptions

        protected final Options mOptions
      • mNamespaces

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

        protected boolean mStarted
      • mNamespacesWritten

        protected boolean mNamespacesWritten
      • currentSubject

        protected Resource currentSubject
      • currentTriples

        protected com.google.common.collect.Multimap<IRI,​Value> currentTriples
    • Constructor Detail

      • StreamingJSONLDWriter

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

      • 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()
        Description copied from interface: RDFWriter
        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
      • startActiveContext

        protected void startActiveContext​(Resource context)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • closeActiveContext

        protected void closeActiveContext()
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • comment

        public void comment​(@Nonnull
                            java.lang.String theComment)
        Description copied from interface: RDFWriter
        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
                              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()
      • writeTypes

        protected void writeTypes​(java.util.Collection<Value> types)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • writePredicateValues

        protected void writePredicateValues​(IRI predicate,
                                            java.util.Collection<Value> values)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writePredicateValues

        protected void writePredicateValues​(java.lang.String predicate,
                                            java.util.Collection<Value> values,
                                            boolean onlyResources)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeValue

        protected void writeValue​(@Nonnull
                                  Value theValue)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • formatResource

        protected java.lang.String formatResource​(Resource res)
      • formatIRI

        protected java.lang.String formatIRI​(IRI iri)
      • writeLiteral

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

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