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 classStreamingJSONLDWriter.StreamingJSONLDWriterFactoryFactoryfor creatingStreamingJSONLDWriter
-
Field Summary
Fields Modifier and Type Field Description protected ResourcecurrentSubjectprotected com.google.common.collect.Multimap<IRI,Value>currentTriplesprotected java.util.Map<java.lang.String,java.lang.String>mNamespacesprotected booleanmNamespacesWrittenprotected OptionsmOptionsprotected booleanmStartedprotected com.fasterxml.jackson.core.JsonGeneratormWriter
-
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 voidcloseActiveContext()protected voidclosePreviousStatement()voidcomment(java.lang.String theComment)Write a comment to the output.voidend()Signals the writing process is completed.RDFFormatformat()Theformatthis writer will serialize output in.protected java.lang.StringformatIRI(IRI iri)protected java.lang.StringformatResource(Resource res)voidhandle(Statement theStmt)Write the givenStatementvoidnamespace(java.lang.String thePrefix, java.lang.String theIRI)Provide a namespace to the writer.voidstart()Signals that the RDF writing process is starting.protected voidstartActiveContext(Resource context)protected voidwriteLiteral(Literal literal)protected voidwritePredicateValues(IRI predicate, java.util.Collection<Value> values)protected voidwritePredicateValues(java.lang.String predicate, java.util.Collection<Value> values, boolean onlyResources)protected voidwriteTypes(java.util.Collection<Value> types)protected voidwriteValue(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:
startin interfaceRDFHandler- Specified by:
startin interfaceRDFWriter
-
end
public void end()
Description copied from interface:RDFWriterSignals the writing process is completed. The underlyingInputStreamis *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:
endin interfaceRDFHandler- Specified by:
endin 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:RDFWriterWrite a comment to the output. Writing need not bestartedat this point; comments can be written prior to any actual serialized RDF
-
handle
public void handle(@Nonnull Statement theStmt)Description copied from interface:RDFWriterWrite the givenStatement- Specified by:
handlein interfaceRDFHandler- Specified by:
handlein 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:
namespacein interfaceRDFHandler- Specified by:
namespacein 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
-
-