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 java.lang.Object implements RDFWriter
Streaming writer for JSON-LD
- Author:
- Evren Sirin
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StreamingJSONLDWriter.StreamingJSONLDWriterFactory
Factory
for creatingStreamingJSONLDWriter
-
Field Summary
Fields Modifier and Type Field Description protected Resource
currentSubject
protected com.google.common.collect.Multimap<IRI,Value>
currentTriples
protected java.util.Map<java.lang.String,java.lang.String>
mNamespaces
protected boolean
mNamespacesWritten
protected Options
mOptions
protected boolean
mStarted
protected com.fasterxml.jackson.core.JsonGenerator
mWriter
-
Constructor Summary
Constructors Constructor Description StreamingJSONLDWriter(java.io.OutputStream theWriter, Options theOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeActiveContext()
protected void
closePreviousStatement()
void
comment(java.lang.String theComment)
Write a comment to the output.void
end()
Signals the writing process is completed.RDFFormat
format()
Theformat
this writer will serialize output in.protected java.lang.String
formatIRI(IRI iri)
protected java.lang.String
formatResource(Resource res)
void
handle(Statement theStmt)
Write the givenStatement
void
namespace(java.lang.String thePrefix, java.lang.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, java.util.Collection<Value> values)
protected void
writePredicateValues(java.lang.String predicate, java.util.Collection<Value> values, boolean onlyResources)
protected void
writeTypes(java.util.Collection<Value> types)
protected void
writeValue(Value theValue)
-
-
-
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
-
-
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 interfaceRDFHandler
- Specified by:
start
in interfaceRDFWriter
-
end
public void end()
Description copied from interface:RDFWriter
Signals the writing process is completed. The underlyingInputStream
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 interfaceRDFHandler
- Specified by:
end
in interfaceRDFWriter
-
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 bestarted
at this point; comments can be written prior to any actual serialized RDF
-
handle
public void handle(@Nonnull Statement theStmt)
Description copied from interface:RDFWriter
Write the givenStatement
- Specified by:
handle
in interfaceRDFHandler
- Specified by:
handle
in interfaceRDFWriter
- Parameters:
theStmt
- the statement 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 hasstarted
, in which case, the namespace bindings are buffered and written when appropriate after writing has begun.- Specified by:
namespace
in interfaceRDFHandler
- Specified by:
namespace
in interfaceRDFWriter
- Parameters:
thePrefix
- the namespace prefixtheIRI
- 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
-
-