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 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 final class`
  `RDFXMLWriter.RDFXMLWriterFactory`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected String`
  `defaultNamespace`
  `protected boolean`
  `headerWritten`
  `protected Resource`
  `lastWrittenSubject`
  `protected final Options`
  `mOptions`
  `protected final Writer`
  `mWriter`
  `protected Map<String,String>`
  `namespaceTable`
  `protected boolean`
  `writingStarted`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RDFXMLWriter(OutputStream theStream, Options theOptions)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `comment(String comment)`
  Write a comment to the output.
  `void`
  `end()`
  Signals the writing process is completed.
  `protected void`
  `flushPendingStatements()`
  `RDFFormat`
  `format()`
  The `format` this writer will serialize output in.
  `protected String`
  `getValidNodeId(BNode theBNode)`
  Create a syntactically valid node id from the supplied blank node id.
  `void`
  `handle(Statement theStmt)`
  Write the given `Statement`
  `void`
  `namespace(String prefix, String name)`
  Provide a namespace to the writer.
  `protected String`
  `setNamespace(String prefix, String name)`
  `void`
  `start()`
  Signals that the RDF writing process is starting.
  `protected void`
  `writeAttribute(String attName, String value)`
  `protected void`
  `writeAttribute(String namespace, String attName, String value)`
  `protected void`
  `writeCharacterData(String chars)`
  `protected void`
  `writeEndOfEmptyTag()`
  `protected void`
  `writeEndOfStartTag()`
  `protected void`
  `writeEndTag(String namespace, String localName)`
  `protected void`
  `writeHeader()`
  `protected void`
  `writeIndent()`
  `protected void`
  `writeNewLine()`
  `protected void`
  `writeStartOfStartTag(String theNamespace, String theLocalName)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### mWriter

    protected final Writer mWriter

  - ### mOptions

    protected final Options mOptions

  - ### defaultNamespace

    protected String defaultNamespace

  - ### writingStarted

    protected boolean writingStarted

  - ### headerWritten

    protected boolean headerWritten

  - ### lastWrittenSubject

    protected Resource lastWrittenSubject

  - ### namespaceTable

    protected Map<String,String> namespaceTable

- ## Constructor Details

  - ### RDFXMLWriter

    public RDFXMLWriter(OutputStream theStream, Options theOptions)

- ## Method Details

  - ### start

    public void start() throws WritingFailed
    Signals that the RDF writing process is starting.
    Specified by:
      `start` in interface `RDFHandler`
    Specified by:
      `start` in interface `RDFWriter`
    Throws:
      `WritingFailed`

  - ### writeHeader

    protected void writeHeader() throws IOException
    Throws:
      `IOException`

  - ### end

    public void end() throws WritingFailed
    Signals the writing process is completed. The underlying `InputStream` is *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:
      `end` in interface `RDFHandler`
    Specified by:
      `end` in interface `RDFWriter`
    Throws:
      `WritingFailed`

  - ### namespace

    public void namespace(@Nonnull String prefix, @Nonnull String name)
    Provide a namespace to the writer. This method can be called before writing has `started`, in which case, the namespace bindings are buffered and written when appropriate after writing has begun.
    Specified by:
      `namespace` in interface `RDFHandler`
    Specified by:
      `namespace` in interface `RDFWriter`
    Parameters:
      `prefix` - the namespace prefix
      `name` - the associated IRI

  - ### setNamespace

    protected String setNamespace(String prefix, String name)

  - ### handle

    public void handle(@Nonnull Statement theStmt) throws WritingFailed
    Write the given `Statement`
    Specified by:
      `handle` in interface `RDFHandler`
    Specified by:
      `handle` in interface `RDFWriter`
    Parameters:
      `theStmt` - the statement to write
    Throws:
      `WritingFailed`

  - ### comment

    public void comment(@Nonnull String comment) throws WritingFailed
    Write a comment to the output. Writing need not be `started` at this point; comments can be written prior to any actual serialized RDF
    Specified by:
      `comment` in interface `RDFWriter`
    Parameters:
      `comment` - the comment to write
    Throws:
      `WritingFailed`

  - ### flushPendingStatements

    protected void flushPendingStatements() throws IOException, WritingFailed
    Throws:
      `IOException`
      `WritingFailed`

  - ### writeStartOfStartTag

    protected void writeStartOfStartTag(@Nonnull String theNamespace, @Nonnull String theLocalName) throws IOException
    Throws:
      `IOException`

  - ### writeAttribute

    protected void writeAttribute(String attName, String value) throws IOException
    Throws:
      `IOException`

  - ### writeAttribute

    protected void writeAttribute(String namespace, String attName, String value) throws IOException, WritingFailed
    Throws:
      `IOException`
      `WritingFailed`

  - ### writeEndOfStartTag

    protected void writeEndOfStartTag() throws IOException
    Throws:
      `IOException`

  - ### writeEndOfEmptyTag

    protected void writeEndOfEmptyTag() throws IOException
    Throws:
      `IOException`

  - ### writeEndTag

    protected void writeEndTag(String namespace, String localName) throws IOException
    Throws:
      `IOException`

  - ### writeCharacterData

    protected void writeCharacterData(String chars) throws IOException
    Throws:
      `IOException`

  - ### writeIndent

    protected void writeIndent() throws IOException
    Throws:
      `IOException`

  - ### writeNewLine

    protected void writeNewLine() throws IOException
    Throws:
      `IOException`

  - ### getValidNodeId

    protected String getValidNodeId(@Nonnull BNode theBNode) throws IOException
    Create 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:
      `IOException`
    See Also:
      - section 7.2.34 of the RDF/XML Syntax specification

  - ### format

    @Nonnull public RDFFormat format()
    The `format` this writer will serialize output in.
    Specified by:
      `format` in interface `RDFWriter`
    Returns:
      the format