Class RDFXMLPrettyWriter
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,CharSink
,Sink
,RDFHandler
,RDFWriter
This is a quasi-streaming RDFWriter. Statements are cached as long as the striped syntax is followed (i.e. the subject of the next statement is the object of the previous statement) and written to the output when the stripe is broken.
The abbreviations used are typed node elements, empty property elements and striped syntax. Note that these abbreviations require that statements are written in the appropriate order.
Striped syntax means that when the object of a statement is the subject of the next statement we can nest the descriptions in each other.
Example:
<rdf:Seq> <rdf:li> <foaf:Person> <foaf:knows> <foaf:Person> <foaf:mbox rdf:resource="..."/> </foaf:Person> </foaf:knows> </foaf:Person> </rdf:li> </rdf:Seq>
Typed node elements means that we write out type information in the short form of
<foaf:Person rdf:about="..."> ... </foaf:Person>
instead of
<rdf:Description rdf:about="..."> <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/> ... </rdf:Description>
Empty property elements are of the form
<foaf:Person> <foaf:homepage rdf:resource="http://www.cs.vu.nl/˜marta"/> </foaf:Person>
instead of
<foaf:Person> <foaf:homepage> <rdf:Description rdf:about="http://www.cs.vu.nl/˜marta"/> <foaf:homepage> </foaf:Person>
- Author:
- Peter Mika (pmika@cs.vu.nl)
-
Field Summary
Fields inherited from class org.eclipse.rdf4j.rio.rdfxml.RDFXMLWriter
baseIRI, defaultNamespace, entityQuote, headerWritten, lastWrittenSubject, quote, writer
Fields inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter
namespaceTable, statementConsumer
-
Constructor Summary
ConstructorDescriptionCreates a new RDFXMLPrintWriter that will write to the supplied OutputStream.RDFXMLPrettyWriter
(OutputStream out, ParsedIRI baseIRI) Creates a new RDFXMLPrintWriter that will write to the supplied OutputStream.RDFXMLPrettyWriter
(Writer out) Creates a new RDFXMLPrintWriter that will write to the supplied Writer.RDFXMLPrettyWriter
(Writer writer, ParsedIRI baseIRI) Creates a new RDFXMLPrintWriter that will write to the supplied Writer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Consume a statement.void
endRDF()
Signals the end of the RDF data.void
flush()
protected void
Collection<RioSetting<?>>
protected void
protected void
writeIndents
(int n) Writes n indents.protected void
writeStartTag
(String namespace, String localName) Methods inherited from class org.eclipse.rdf4j.rio.rdfxml.RDFXMLWriter
getRDFFormat, getValidNodeId, getWriter, handleComment, handleNamespace, setNamespace, writeAttribute, writeAttribute, writeCharacterData, writeEndOfEmptyTag, writeEndOfStartTag, writeEndTag, writeIndent, writeNewLine, writeQuotedAttribute, writeStartOfStartTag
Methods inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFWriter
checkWritingStarted, getFileFormat, getWriterConfig, handleStatement, isWritingStarted, set, setWriterConfig, startRDF
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.rdf4j.common.io.Sink
acceptsFileFormat, getFileFormat
-
Constructor Details
-
RDFXMLPrettyWriter
Creates a new RDFXMLPrintWriter that will write to the supplied OutputStream.- Parameters:
out
- The OutputStream to write the RDF/XML document to.
-
RDFXMLPrettyWriter
Creates a new RDFXMLPrintWriter that will write to the supplied OutputStream.- Parameters:
out
- The OutputStream to write the RDF/XML document to.
-
RDFXMLPrettyWriter
Creates a new RDFXMLPrintWriter that will write to the supplied Writer.- Parameters:
out
- The Writer to write the RDF/XML document to.
-
RDFXMLPrettyWriter
Creates a new RDFXMLPrintWriter that will write to the supplied Writer.- Parameters:
writer
- the Writer to write the RDF/XML document tobaseIRI
- base IRI
-
-
Method Details
-
endRDF
Description copied from interface:RDFHandler
Signals the end of the RDF data. This method is called when all data has been reported.- Specified by:
endRDF
in interfaceRDFHandler
- Overrides:
endRDF
in classRDFXMLWriter
- Throws:
RDFHandlerException
- If the RDF handler has encountered an unrecoverable error.
-
writeHeader
- Overrides:
writeHeader
in classRDFXMLWriter
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Throws:
IOException
-
getSupportedSettings
- Specified by:
getSupportedSettings
in interfaceRDFWriter
- Overrides:
getSupportedSettings
in classRDFXMLWriter
- Returns:
- A collection of
RioSetting
s that are supported by this RDFWriter.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
flushPendingStatements
- Overrides:
flushPendingStatements
in classRDFXMLWriter
- Throws:
IOException
RDFHandlerException
-
consumeStatement
Description copied from class:AbstractRDFWriter
Consume a statement.Extending classes must override this method instead of overriding
AbstractRDFWriter.handleStatement(Statement)
in order to benefit from automatic handling of RDF-star conversion or encoding.- Overrides:
consumeStatement
in classRDFXMLWriter
- Parameters:
st
- the statement to consume.- Throws:
RDFHandlerException
-
writeStartTag
- Throws:
IOException
-
writeIndents
Writes n indents.- Throws:
IOException
-