Interface StaxWriter<N>

All Known Implementing Classes:
StaxWriterImpl

public interface StaxWriter<N>
Version:
$Revision$
Author:
Nick Scavelli
  • Method Details

    • writeStartElement

      StaxWriter<N> writeStartElement(N element) throws org.staxnav.StaxNavException
      Writes the start tag of an xml element. Requires that an element has been started first.
      Parameters:
      element - element to start
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeAttribute

      StaxWriter<N> writeAttribute(String name, String value) throws org.staxnav.StaxNavException
      Writes an attribute for an xml element. Requires that an element has been started first.
      Parameters:
      name - the name of the attribute
      value - the value of the attribute
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeAttribute

      StaxWriter<N> writeAttribute(QName name, String value) throws org.staxnav.StaxNavException
      Writes an attribute for an xml element. Requires that an element has been started first.
      Parameters:
      name - QName object representing the name of the attribute
      value - the value of the attribute
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeContent

      StaxWriter<N> writeContent(String content) throws org.staxnav.StaxNavException
      Writes xml content. Requires an xml element has been started first.
      Parameters:
      content - content to be written
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeContent

      <V> StaxWriter<N> writeContent(WritableValueType<V> valueType, V content) throws org.staxnav.StaxNavException
      Writes xml content based on the ValueType responsible for converting the content to string. Requires an xml element has been started first.
      Parameters:
      valueType - object responsible for writing content to string
      content - content to be written
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeEndElement

      StaxWriter<N> writeEndElement() throws org.staxnav.StaxNavException
      Writes an end tag for the previously started element. Requires that an element has been started first.
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeElement

      <V> StaxWriter<N> writeElement(N element, String content) throws org.staxnav.StaxNavException
      Convenience method for calling writeStartElement, writeContent, writeEndElement
      Parameters:
      element - element to write
      content - content to be written
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeElement

      <V> StaxWriter<N> writeElement(N element, WritableValueType<V> valueType, V content) throws org.staxnav.StaxNavException
      Convenience method for calling writeStartElement, writeContent, writeEndElement
      Parameters:
      element - element to write
      valueType - object responsible for writing content to string
      content - content to be written
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeNamespace

      StaxWriter<N> writeNamespace(String prefix, String uri) throws org.staxnav.StaxNavException
      Writes the namespace. If prefix is an empty string, "xmlns", or null this will delegate to writeDefaultNamespace
      Parameters:
      prefix - the prefix to bind the namespace to
      uri - the uri to bind the prefix to
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeDefaultNamespace

      StaxWriter<N> writeDefaultNamespace(String uri) throws org.staxnav.StaxNavException
      Writes the default namespace
      Parameters:
      uri - the uri to bind the default namespace to
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeComment

      StaxWriter<N> writeComment(String comment) throws org.staxnav.StaxNavException
      Writes an xml comment
      Parameters:
      comment - the comment to write
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • writeCData

      StaxWriter<N> writeCData(String cdata) throws org.staxnav.StaxNavException
      Writes a cdata section
      Parameters:
      cdata - content of the cdata
      Returns:
      StaxWriter
      Throws:
      org.staxnav.StaxNavException - if an exception occurs
    • finish

      void finish() throws org.staxnav.StaxNavException
      Calling finish will flush and close the underlying stream. It will also call any endElements for you if they were never explicitly called.
      Throws:
      org.staxnav.StaxNavException - if an exception occurs