Package com.stardog.stark.io.jsonld

# Class StreamingJSONLDWriter

java.lang.Object
com.stardog.stark.io.jsonld.StreamingJSONLDWriter

All Implemented Interfaces:
  `RDFHandler`, `RDFWriter`

public class StreamingJSONLDWriter extends Object implements RDFWriter

Streaming writer for JSON-LD

Author:
  Evren Sirin

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static final class`
  `StreamingJSONLDWriter.StreamingJSONLDWriterFactory`
  `Factory` for creating `StreamingJSONLDWriter`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Resource`
  `currentSubject`
  `protected com.google.common.collect.Multimap<IRI,Value>`
  `currentTriples`
  `protected final Map<String,String>`
  `mNamespaces`
  `protected boolean`
  `mNamespacesWritten`
  `protected final Options`
  `mOptions`
  `protected boolean`
  `mStarted`
  `protected final com.fasterxml.jackson.core.JsonGenerator`
  `mWriter`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StreamingJSONLDWriter(OutputStream theWriter, Options theOptions)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `closeActiveContext()`
  `protected void`
  `closePreviousStatement()`
  `void`
  `comment(String theComment)`
  Write a comment to the output.
  `void`
  `end()`
  Signals the writing process is completed.
  `RDFFormat`
  `format()`
  The `format` this writer will serialize output in.
  `protected String`
  `formatIRI(IRI iri)`
  `protected String`
  `formatResource(Resource res)`
  `void`
  `handle(Statement theStmt)`
  Write the given `Statement`
  `void`
  `namespace(String thePrefix, String theIRI)`
  Provide a namespace to the writer.
  `void`
  `start()`
  Signals that the RDF writing process is starting.
  `protected void`
  `startActiveContext(Resource context)`
  `protected void`
  `writeLiteral(Literal literal)`
  `protected void`
  `writePredicateValues(IRI predicate, Collection<Value> values)`
  `protected void`
  `writePredicateValues(String predicate, Collection<Value> values, boolean onlyResources)`
  `protected void`
  `writeTypes(Collection<Value> types)`
  `protected void`
  `writeValue(Value theValue)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### mWriter

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

  - ### mOptions

    protected final Options mOptions

  - ### mNamespaces

    protected final Map<String,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 Details

  - ### StreamingJSONLDWriter

    public StreamingJSONLDWriter(OutputStream theWriter, Options theOptions)

- ## Method Details

  - ### 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 IOException
    Throws:
      `IOException`

  - ### closeActiveContext

    protected void closeActiveContext() throws IOException
    Throws:
      `IOException`

  - ### comment

    public void comment(@Nonnull 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

  - ### handle

    public void handle(@Nonnull Statement theStmt)
    Description copied from interface: `RDFWriter`
    Write the given `Statement`
    Specified by:
      `handle` in interface `RDFHandler`
    Specified by:
      `handle` in interface `RDFWriter`
    Parameters:
      `theStmt` - the statement 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

  - ### closePreviousStatement

    protected void closePreviousStatement()

  - ### writeTypes

    protected void writeTypes(Collection<Value> types) throws IOException
    Throws:
      `IOException`

  - ### writePredicateValues

    protected void writePredicateValues(IRI predicate, Collection<Value> values) throws IOException
    Throws:
      `IOException`

  - ### writePredicateValues

    protected void writePredicateValues(String predicate, Collection<Value> values, boolean onlyResources) throws IOException
    Throws:
      `IOException`

  - ### writeValue

    protected void writeValue(@Nonnull Value theValue) throws IOException
    Throws:
      `IOException`

  - ### formatResource

    protected String formatResource(Resource res)

  - ### formatIRI

    protected String formatIRI(IRI iri)

  - ### writeLiteral

    protected void writeLiteral(@Nonnull Literal literal) throws IOException
    Throws:
      `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