public class TurtleWriter extends AbstractRDFWriter implements RDFWriter
| Modifier and Type | Field and Description |
|---|---|
protected ParsedIRI |
baseIRI |
protected Model |
bufferedStatements |
protected IRI |
lastWrittenPredicate |
protected Resource |
lastWrittenSubject |
protected boolean |
statementClosed
Flag indicating whether the last written statement has been closed.
|
protected IndentingWriter |
writer |
namespaceTable, statementConsumer| Constructor and Description |
|---|
TurtleWriter(OutputStream out)
Creates a new TurtleWriter that will write to the supplied OutputStream.
|
TurtleWriter(OutputStream out,
ParsedIRI baseIRI)
Creates a new TurtleWriter that will write to the supplied OutputStream.
|
TurtleWriter(Writer writer)
Creates a new TurtleWriter that will write to the supplied Writer.
|
TurtleWriter(Writer writer,
ParsedIRI baseIRI)
Creates a new TurtleWriter that will write to the supplied Writer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
closePreviousStatement() |
protected void |
consumeStatement(Statement st)
Consume a statement.
|
void |
endRDF()
Signals the end of the RDF data.
|
protected ModelFactory |
getModelFactory() |
RDFFormat |
getRDFFormat()
Gets the RDF format that this RDFWriter uses.
|
void |
handleComment(String comment)
Handles a comment.
|
void |
handleNamespace(String prefix,
String name)
Handles a namespace declaration/definition.
|
protected void |
handleStatementInternal(Statement st,
boolean endRDFCalled,
boolean canShortenSubjectBNode,
boolean canShortenObjectBNode)
Internal method that differentiates between the pretty-print and streaming writer cases.
|
void |
setModelFactory(ModelFactory modelFactory)
Set a
ModelFactory to use for creating internal Models for statement processing/buffering purposes. |
void |
startRDF()
Signals the start of the RDF data.
|
protected void |
writeBase(String baseURI) |
protected void |
writeBNode(BNode bNode)
Deprecated.
Use
writeBNode(BNode, boolean) instead. |
protected void |
writeBNode(BNode bNode,
boolean canShorten) |
protected void |
writeCommentLine(String line) |
protected void |
writeLiteral(Literal lit) |
protected void |
writeNamespace(String prefix,
String name) |
protected void |
writePredicate(IRI predicate) |
protected void |
writeResource(Resource res)
Deprecated.
Use
writeResource(Resource, boolean) instead. |
protected void |
writeResource(Resource res,
boolean canShorten)
|
protected void |
writeStatement(Resource subj,
IRI pred,
Value obj,
Resource context,
boolean canShortenSubjectBNode,
boolean canShortenObjectBNode) |
protected void |
writeTriple(Triple triple,
boolean canShorten) |
protected void |
writeTripleRDFStar(Triple triple,
boolean canShorten) |
protected void |
writeURI(IRI uri) |
protected void |
writeValue(Value val)
Deprecated.
Use
writeValue(Value, boolean) instead. |
protected void |
writeValue(Value val,
boolean canShorten)
|
checkWritingStarted, getOutputStream, getSupportedSettings, getWriterConfig, handleStatement, isWritingStarted, set, setWriterConfigclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetOutputStream, getSupportedSettings, getWriterConfig, set, setWriterConfighandleStatementprotected Model bufferedStatements
protected ParsedIRI baseIRI
protected IndentingWriter writer
protected boolean statementClosed
protected Resource lastWrittenSubject
protected IRI lastWrittenPredicate
public TurtleWriter(OutputStream out)
out - The OutputStream to write the Turtle document to.public TurtleWriter(OutputStream out, ParsedIRI baseIRI)
out - The OutputStream to write the Turtle document to.baseIRI - public TurtleWriter(Writer writer)
writer - The Writer to write the Turtle document to.public RDFFormat getRDFFormat()
RDFWritergetRDFFormat in interface RDFWriterpublic void startRDF()
throws RDFHandlerException
RDFHandlerstartRDF in interface RDFHandlerstartRDF in class AbstractRDFWriterRDFHandlerException - If the RDF handler has encountered an unrecoverable error.public void endRDF()
throws RDFHandlerException
RDFHandlerendRDF in interface RDFHandlerRDFHandlerException - If the RDF handler has encountered an unrecoverable error.public void handleNamespace(String prefix, String name) throws RDFHandlerException
RDFHandlerhandleNamespace in interface RDFHandlerhandleNamespace in class AbstractRDFWriterprefix - The prefix for the namespace, or an empty string in case of a default namespace.name - The URI that the prefix maps to.RDFHandlerException - If the RDF handler has encountered an unrecoverable error.public void setModelFactory(ModelFactory modelFactory)
ModelFactory to use for creating internal Models for statement processing/buffering purposes.modelFactory - a ModelFactory to use for internal buffering / statement processing purposes. May not
be null.protected ModelFactory getModelFactory()
protected void consumeStatement(Statement st) throws RDFHandlerException
AbstractRDFWriterAbstractRDFWriter.handleStatement(Statement) in order to
benefit from automatic handling of RDF* conversion or encoding.consumeStatement in class AbstractRDFWriterst - the statement to consume.RDFHandlerExceptionprotected void handleStatementInternal(Statement st, boolean endRDFCalled, boolean canShortenSubjectBNode, boolean canShortenObjectBNode)
st - The next statement to writeendRDFCalled - True if endRDF has been called before this method is called. This is used to buffer
statements for pretty-printing before dumping them when all statements have been
delivered to us.canShortenSubjectBNode - True if, in the current context, we may be able to shorten the subject of this
statement iff it is an instance of BNode.canShortenObjectBNode - True if, in the current context, we may be able to shorten the object of this
statement iff it is an instance of BNode.protected void writeStatement(Resource subj, IRI pred, Value obj, Resource context, boolean canShortenSubjectBNode, boolean canShortenObjectBNode) throws IOException
IOExceptionpublic void handleComment(String comment) throws RDFHandlerException
RDFHandlerhandleComment in interface RDFHandlercomment - The comment.RDFHandlerException - If the RDF handler has encountered an unrecoverable error.protected void writeCommentLine(String line) throws IOException
IOExceptionprotected void writeBase(String baseURI) throws IOException
IOExceptionprotected void writeNamespace(String prefix, String name) throws IOException
IOExceptionprotected void writePredicate(IRI predicate) throws IOException
IOException@Deprecated protected void writeValue(Value val) throws IOException
writeValue(Value, boolean) instead.val - The Value to write.IOExceptionprotected void writeValue(Value val, boolean canShorten) throws IOException
IRI and has a namespace definition that is suitable
for use in this context for shortening or a BNode that has been confirmed to be able to be shortened in
this context.val - The Value to write.canShorten - True if, in the current context, we can shorten this value if it is an instance of
BNode .IOException@Deprecated protected void writeResource(Resource res) throws IOException
writeResource(Resource, boolean) instead.res - The Resource to write.IOExceptionprotected void writeResource(Resource res, boolean canShorten) throws IOException
Resource, optionally shortening it if it is an IRI and has a namespace definition that
is suitable for use in this context for shortening or a BNode that has been confirmed to be able to be
shortened in this context.res - The Resource to write.canShorten - True if, in the current context, we can shorten this value if it is an instance of
BNode .IOExceptionprotected void writeURI(IRI uri) throws IOException
IOException@Deprecated protected void writeBNode(BNode bNode) throws IOException
writeBNode(BNode, boolean) instead.bNode - The BNode to write.IOExceptionprotected void writeBNode(BNode bNode, boolean canShorten) throws IOException
IOExceptionprotected void writeTriple(Triple triple, boolean canShorten) throws IOException
IOExceptionprotected void writeTripleRDFStar(Triple triple, boolean canShorten) throws IOException
IOExceptionprotected void writeLiteral(Literal lit) throws IOException
IOExceptionprotected void closePreviousStatement()
throws IOException
IOExceptionCopyright © 2015-2020 Eclipse Foundation. All Rights Reserved.