Package com.stardog.stark.io.rdfxml
Class RDFXMLWriter
- java.lang.Object
-
- com.stardog.stark.io.rdfxml.RDFXMLWriter
-
- All Implemented Interfaces:
RDFHandler,RDFWriter
- Direct Known Subclasses:
RDFXMLPrettyWriter
public class RDFXMLWriter extends java.lang.Object implements RDFWriter
Default writer for the RDF/XML serialization
- Since:
- 1.0
- Version:
- 1.0
- Author:
- Michael Grove
- See Also:
RDFXMLParser,RDFFormats.RDFXML
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRDFXMLWriter.RDFXMLWriterFactory
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringdefaultNamespaceprotected booleanheaderWrittenprotected ResourcelastWrittenSubjectprotected OptionsmOptionsprotected java.io.WritermWriterprotected java.util.Map<java.lang.String,java.lang.String>namespaceTableprotected booleanwritingStarted
-
Constructor Summary
Constructors Constructor Description RDFXMLWriter(java.io.OutputStream theStream, Options theOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomment(java.lang.String comment)Write a comment to the output.voidend()Signals the writing process is completed.protected voidflushPendingStatements()RDFFormatformat()Theformatthis writer will serialize output in.protected java.lang.StringgetValidNodeId(BNode theBNode)Create a syntactically valid node id from the supplied blank node id.voidhandle(Statement theStmt)Write the givenStatementvoidnamespace(java.lang.String prefix, java.lang.String name)Provide a namespace to the writer.protected java.lang.StringsetNamespace(java.lang.String prefix, java.lang.String name)voidstart()Signals that the RDF writing process is starting.protected voidwriteAttribute(java.lang.String attName, java.lang.String value)protected voidwriteAttribute(java.lang.String namespace, java.lang.String attName, java.lang.String value)protected voidwriteCharacterData(java.lang.String chars)protected voidwriteEndOfEmptyTag()protected voidwriteEndOfStartTag()protected voidwriteEndTag(java.lang.String namespace, java.lang.String localName)protected voidwriteHeader()protected voidwriteIndent()protected voidwriteNewLine()protected voidwriteStartOfStartTag(java.lang.String theNamespace, java.lang.String theLocalName)
-
-
-
Field Detail
-
mWriter
protected final java.io.Writer mWriter
-
mOptions
protected final Options mOptions
-
defaultNamespace
protected java.lang.String defaultNamespace
-
writingStarted
protected boolean writingStarted
-
headerWritten
protected boolean headerWritten
-
lastWrittenSubject
protected Resource lastWrittenSubject
-
namespaceTable
protected java.util.Map<java.lang.String,java.lang.String> namespaceTable
-
-
Constructor Detail
-
RDFXMLWriter
public RDFXMLWriter(java.io.OutputStream theStream, Options theOptions)
-
-
Method Detail
-
start
public void start() throws WritingFailedSignals that the RDF writing process is starting.- Specified by:
startin interfaceRDFHandler- Specified by:
startin interfaceRDFWriter- Throws:
WritingFailed
-
writeHeader
protected void writeHeader() throws java.io.IOException- Throws:
java.io.IOException
-
end
public void end() throws WritingFailedSignals 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- Throws:
WritingFailed
-
namespace
public void namespace(@Nonnull java.lang.String prefix, @Nonnull java.lang.String name)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:
prefix- the namespace prefixname- the associated IRI
-
setNamespace
protected java.lang.String setNamespace(java.lang.String prefix, java.lang.String name)
-
handle
public void handle(@Nonnull Statement theStmt) throws WritingFailedWrite the givenStatement- Specified by:
handlein interfaceRDFHandler- Specified by:
handlein interfaceRDFWriter- Parameters:
theStmt- the statement to write- Throws:
WritingFailed
-
comment
public void comment(@Nonnull java.lang.String comment) throws WritingFailedWrite a comment to the output. Writing need not bestartedat this point; comments can be written prior to any actual serialized RDF- Specified by:
commentin interfaceRDFWriter- Parameters:
comment- the comment to write- Throws:
WritingFailed
-
flushPendingStatements
protected void flushPendingStatements() throws java.io.IOException, WritingFailed- Throws:
java.io.IOExceptionWritingFailed
-
writeStartOfStartTag
protected void writeStartOfStartTag(@Nonnull java.lang.String theNamespace, @Nonnull java.lang.String theLocalName) throws java.io.IOException- Throws:
java.io.IOException
-
writeAttribute
protected void writeAttribute(java.lang.String attName, java.lang.String value) throws java.io.IOException- Throws:
java.io.IOException
-
writeAttribute
protected void writeAttribute(java.lang.String namespace, java.lang.String attName, java.lang.String value) throws java.io.IOException, WritingFailed- Throws:
java.io.IOExceptionWritingFailed
-
writeEndOfStartTag
protected void writeEndOfStartTag() throws java.io.IOException- Throws:
java.io.IOException
-
writeEndOfEmptyTag
protected void writeEndOfEmptyTag() throws java.io.IOException- Throws:
java.io.IOException
-
writeEndTag
protected void writeEndTag(java.lang.String namespace, java.lang.String localName) throws java.io.IOException- Throws:
java.io.IOException
-
writeCharacterData
protected void writeCharacterData(java.lang.String chars) throws java.io.IOException- Throws:
java.io.IOException
-
writeIndent
protected void writeIndent() throws java.io.IOException- Throws:
java.io.IOException
-
writeNewLine
protected void writeNewLine() throws java.io.IOException- Throws:
java.io.IOException
-
getValidNodeId
protected java.lang.String getValidNodeId(@Nonnull BNode theBNode) throws java.io.IOExceptionCreate a syntactically valid node id from the supplied blank node id. This is necessary because RDF/XML syntax enforces the blank node id is a valid NCName.- Parameters:
theBNode- a blank node identifier- Returns:
- the blank node identifier converted to a form that is a valid NCName.
- Throws:
java.io.IOException- See Also:
- section 7.2.34 of the RDF/XML Syntax specification
-
-