Package com.stardog.stark.io.turtle
Class TurtleWriter
java.lang.Object
com.stardog.stark.io.turtle.TurtleWriter
- All Implemented Interfaces:
RDFHandler,RDFWriter
- Direct Known Subclasses:
PrettyTurtleWriter,TrigWriter
Default implementation of a writer for Turtle
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidWrite a comment to the output.voidend()Signals the writing process is completed.format()Theformatthis writer will serialize output in.voidWrite the givenStatementvoidProvide a namespace to the writer.voidstart()Signals that the RDF writing process is starting.protected voidwriteBNode(BNode bNode) protected voidwriteCommentLine(String theLine) protected voidwriteEmbeddedTriple(Statement statement) protected voidprotected voidwriteLiteral(Literal theLiteral) protected voidwriteNamespace(String thePrefix, String theIRI) protected voidwritePredicate(IRI predicate) protected voidwriteResource(Resource res) protected voidwriteValue(Value theValue)
-
Field Details
-
mWriter
protected final com.stardog.common.io.block.BlockWriter mWriter -
mOptions
-
mNamespaces
-
mStarted
protected boolean mStarted -
mStmtClosed
protected boolean mStmtClosed -
mLastWrittenSubject
-
mLastWrittenPredicate
-
mBlockSpec
protected com.stardog.common.io.block.BlockSpec mBlockSpec
-
-
Constructor Details
-
TurtleWriter
-
-
Method Details
-
comment
Write a comment to the output. Writing need not bestartedat this point; comments can be written prior to any actual serialized RDF -
writeCommentLine
-
start
public void start()Signals that the RDF writing process is starting.- Specified by:
startin interfaceRDFHandler- Specified by:
startin interfaceRDFWriter
-
handle
Description copied from interface:RDFWriterWrite the givenStatement- Specified by:
handlein interfaceRDFHandler- Specified by:
handlein interfaceRDFWriter- Parameters:
theStmt- the statement to write
-
end
public void end()Signals 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
-
namespace
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() -
writeNamespace
-
writePredicate
- Throws:
IOException
-
writeResource
Writes aResource, optionally shortening it if it is anIRIand has a namespace definition that is suitable for use in this context for shortening or aBNodethat has been confirmed to be able to be shortened in this context.- Parameters:
res- TheResourceto write.- Throws:
IOException- if the write operation to the underlying stream fails
-
writeEmbeddedTriple
- Throws:
IOException
-
writeValue
Writes a value, optionally shortening it if it is anIRIand has a namespace definition that is suitable for use in this context for shortening or aBNodethat has been confirmed to be able to be shortened in this context.- Parameters:
theValue- TheValueto write.- Throws:
IOException- if the write operation to the underlying stream fails
-
writeIRI
- Throws:
IOException
-
writeBNode
- Parameters:
bNode- TheBNodeto write.- Throws:
IOException- if the write operation to the underlying stream fails
-
writeLiteral
- Throws:
IOException
-
format
Theformatthis writer will serialize output in.
-