Class StaxSerializer

  • All Implemented Interfaces:
    XmlSerializer

    public class StaxSerializer
    extends java.lang.Object
    implements XmlSerializer
    XML serializer for StAX XMLStreamWriter. TODO: add support for XMLEventWriter (if it makes sense)
    Author:
    Ryan.Shoemaker@Sun.COM
    • Constructor Summary

      Constructors 
      Constructor Description
      StaxSerializer​(javax.xml.stream.XMLStreamWriter writer)  
      StaxSerializer​(javax.xml.stream.XMLStreamWriter writer, boolean indenting)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void beginStartTag​(java.lang.String uri, java.lang.String localName, java.lang.String prefix)
      Begins writing a start tag.
      void cdata​(java.lang.StringBuilder text)
      Writes CDATA.
      void comment​(java.lang.StringBuilder comment)
      Writes a comment.
      void endDocument()
      The last method to be called.
      void endStartTag​(java.lang.String uri, java.lang.String localName, java.lang.String prefix)
      Completes the start tag.
      void endTag()
      Writes an end tag.
      void flush()
      Flush the buffer.
      void startDocument()
      The first method to be called.
      void text​(java.lang.StringBuilder text)
      Writes PCDATA.
      void writeAttribute​(java.lang.String uri, java.lang.String localName, java.lang.String prefix, java.lang.StringBuilder value)
      Writes an attribute.
      void writeXmlns​(java.lang.String prefix, java.lang.String uri)
      Writes a namespace declaration.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StaxSerializer

        public StaxSerializer​(javax.xml.stream.XMLStreamWriter writer)
      • StaxSerializer

        public StaxSerializer​(javax.xml.stream.XMLStreamWriter writer,
                              boolean indenting)
    • Method Detail

      • beginStartTag

        public void beginStartTag​(java.lang.String uri,
                                  java.lang.String localName,
                                  java.lang.String prefix)
        Description copied from interface: XmlSerializer
        Begins writing a start tag.
        Specified by:
        beginStartTag in interface XmlSerializer
        Parameters:
        uri - the namespace URI of the element. Can be empty but never be null.
        prefix - the prefix that should be used for this element. Can be empty, but never null.
      • writeAttribute

        public void writeAttribute​(java.lang.String uri,
                                   java.lang.String localName,
                                   java.lang.String prefix,
                                   java.lang.StringBuilder value)
        Description copied from interface: XmlSerializer
        Writes an attribute.
        Specified by:
        writeAttribute in interface XmlSerializer
        Parameters:
        uri - the namespace URI of the attribute. Can be empty but never be null.
        prefix - the prefix that should be used for this attribute. Can be empty, but never null.
        value - The value of the attribute. It's the callee's responsibility to escape special characters (such as <, >, and &) in this buffer.
      • writeXmlns

        public void writeXmlns​(java.lang.String prefix,
                               java.lang.String uri)
        Description copied from interface: XmlSerializer
        Writes a namespace declaration.
        Specified by:
        writeXmlns in interface XmlSerializer
        Parameters:
        prefix - the prefix that is allocated. Can be empty but never be null.
        uri - the namespace URI to be declared. Can be empty but never be null.
      • endStartTag

        public void endStartTag​(java.lang.String uri,
                                java.lang.String localName,
                                java.lang.String prefix)
        Description copied from interface: XmlSerializer
        Completes the start tag.
        Specified by:
        endStartTag in interface XmlSerializer
        Parameters:
        uri - the namespace URI of the element. Can be empty but never be null.
        prefix - the prefix that should be used for this element. Can be empty, but never null.
      • text

        public void text​(java.lang.StringBuilder text)
        Description copied from interface: XmlSerializer
        Writes PCDATA.
        Specified by:
        text in interface XmlSerializer
        Parameters:
        text - The character data to be written. It's the callee's responsibility to escape special characters (such as <, >, and &) in this buffer.
      • cdata

        public void cdata​(java.lang.StringBuilder text)
        Description copied from interface: XmlSerializer
        Writes CDATA.
        Specified by:
        cdata in interface XmlSerializer
      • comment

        public void comment​(java.lang.StringBuilder comment)
        Description copied from interface: XmlSerializer
        Writes a comment.
        Specified by:
        comment in interface XmlSerializer
      • flush

        public void flush()
        Description copied from interface: XmlSerializer
        Flush the buffer. This method is called when applications invoke TypedXmlWriter.commit(boolean) method. If the implementation performs any buffering, it should flush the buffer.
        Specified by:
        flush in interface XmlSerializer