public class TurtleWriter extends AbstractRDFWriter implements RDFWriter
Modifier and Type | Field and Description |
---|---|
protected ParsedIRI |
baseIRI |
protected IRI |
lastWrittenPredicate |
protected Resource |
lastWrittenSubject |
protected Model |
prettyPrintModel
Deprecated.
|
protected boolean |
statementClosed
Flag indicating whether the last written statement has been closed.
|
protected IndentingWriter |
writer |
protected boolean |
writingStarted |
namespaceTable
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() |
void |
endRDF()
Signals the end of the RDF data.
|
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.
|
void |
handleStatement(Statement st)
Handles a statement.
|
protected void |
handleStatementInternal(Statement st,
boolean endRDFCalled,
boolean canShortenSubjectBNode,
boolean canShortenObjectBNode)
Internal method that differentiates between the pretty-print and streaming writer cases.
|
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 |
writeURI(IRI uri) |
protected void |
writeValue(Value val)
Deprecated.
Use
writeValue(Value, boolean) instead. |
protected void |
writeValue(Value val,
boolean canShorten)
|
getSupportedSettings, getWriterConfig, set, setWriterConfig
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSupportedSettings, getWriterConfig, set, setWriterConfig
protected ParsedIRI baseIRI
protected IndentingWriter writer
protected boolean writingStarted
protected boolean statementClosed
protected Resource lastWrittenSubject
protected IRI lastWrittenPredicate
@Deprecated protected Model prettyPrintModel
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()
RDFWriter
getRDFFormat
in interface RDFWriter
public void startRDF() throws RDFHandlerException
RDFHandler
startRDF
in interface RDFHandler
RDFHandlerException
- If the RDF handler has encountered an unrecoverable error.public void endRDF() throws RDFHandlerException
RDFHandler
endRDF
in interface RDFHandler
RDFHandlerException
- If the RDF handler has encountered an unrecoverable error.public void handleNamespace(String prefix, String name) throws RDFHandlerException
RDFHandler
handleNamespace
in interface RDFHandler
handleNamespace
in class AbstractRDFWriter
prefix
- 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 handleStatement(Statement st) throws RDFHandlerException
RDFHandler
handleStatement
in interface RDFHandler
st
- The statement.RDFHandlerException
- If the RDF handler has encountered an unrecoverable error.protected 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
.public void handleComment(String comment) throws RDFHandlerException
RDFHandler
handleComment
in interface RDFHandler
comment
- The comment.RDFHandlerException
- If the RDF handler has encountered an unrecoverable error.protected void writeCommentLine(String line) throws IOException
IOException
protected void writeBase(String baseURI) throws IOException
IOException
protected void writeNamespace(String prefix, String name) throws IOException
IOException
protected void writePredicate(IRI predicate) throws IOException
IOException
@Deprecated protected void writeValue(Value val) throws IOException
writeValue(Value, boolean)
instead.val
- The Value
to write.IOException
protected 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.IOException
protected 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
.IOException
protected void writeURI(IRI uri) throws IOException
IOException
@Deprecated protected void writeBNode(BNode bNode) throws IOException
writeBNode(BNode, boolean)
instead.bNode
- The BNode
to write.IOException
protected void writeBNode(BNode bNode, boolean canShorten) throws IOException
IOException
protected void writeLiteral(Literal lit) throws IOException
IOException
protected void closePreviousStatement() throws IOException
IOException
Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.