Class XMLStreamRecorder

  • All Implemented Interfaces:
    javax.xml.stream.XMLStreamWriter

    public class XMLStreamRecorder
    extends XMLWriterBase

    Writes XML in a non-xml format to create XML tests.

    • Constructor Detail

      • XMLStreamRecorder

        public XMLStreamRecorder()
      • XMLStreamRecorder

        public XMLStreamRecorder​(java.io.Writer writer)
    • Method Detail

      • writeName

        protected java.lang.String writeName​(java.lang.String prefix,
                                             java.lang.String namespaceURI,
                                             java.lang.String localName)
                                      throws javax.xml.stream.XMLStreamException
        Overrides:
        writeName in class XMLWriterBase
        Throws:
        javax.xml.stream.XMLStreamException
      • writeType

        protected void writeType​(int type)
                          throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • openStartTag

        protected void openStartTag()
                             throws javax.xml.stream.XMLStreamException
        Overrides:
        openStartTag in class XMLWriterBase
        Throws:
        javax.xml.stream.XMLStreamException
      • closeStartTag

        protected void closeStartTag()
                              throws javax.xml.stream.XMLStreamException
        Overrides:
        closeStartTag in class XMLWriterBase
        Throws:
        javax.xml.stream.XMLStreamException
      • openEndTag

        protected void openEndTag()
                           throws javax.xml.stream.XMLStreamException
        Overrides:
        openEndTag in class XMLWriterBase
        Throws:
        javax.xml.stream.XMLStreamException
      • closeEndTag

        protected void closeEndTag()
                            throws javax.xml.stream.XMLStreamException
        Overrides:
        closeEndTag in class XMLWriterBase
        Throws:
        javax.xml.stream.XMLStreamException
      • writeAttribute

        public void writeAttribute​(java.lang.String namespaceURI,
                                   java.lang.String localName,
                                   java.lang.String value)
                            throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Writes an attribute to the output stream
        Specified by:
        writeAttribute in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeAttribute in class XMLWriterBase
        Parameters:
        namespaceURI - the uri of the prefix for this attribute
        localName - the local name of the attribute
        value - the value of the attribute
        Throws:
        javax.xml.stream.XMLStreamException - if the namespace URI has not been bound to a prefix and javax.xml.stream.isPrefixDefaulting has not been set to true
      • writeNamespace

        public void writeNamespace​(java.lang.String prefix,
                                   java.lang.String namespaceURI)
                            throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Writes a namespace to the output stream If the prefix argument to this method is the empty string, "xmlns", or null this method will delegate to writeDefaultNamespace
        Specified by:
        writeNamespace in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeNamespace in class XMLWriterBase
        Parameters:
        prefix - the prefix to bind this namespace to
        namespaceURI - the uri to bind the prefix to
        Throws:
        javax.xml.stream.XMLStreamException
      • writeDefaultNamespace

        public void writeDefaultNamespace​(java.lang.String namespaceURI)
                                   throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Writes the default namespace to the stream
        Specified by:
        writeDefaultNamespace in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeDefaultNamespace in class XMLWriterBase
        Parameters:
        namespaceURI - the uri to bind the default namespace to
        Throws:
        javax.xml.stream.XMLStreamException
      • writeComment

        public void writeComment​(java.lang.String data)
                          throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Writes an xml comment with the data enclosed
        Specified by:
        writeComment in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeComment in class XMLWriterBase
        Parameters:
        data - the data contained in the comment, may be null
        Throws:
        javax.xml.stream.XMLStreamException
      • writeProcessingInstruction

        public void writeProcessingInstruction​(java.lang.String target,
                                               java.lang.String text)
                                        throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Writes a processing instruction
        Specified by:
        writeProcessingInstruction in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeProcessingInstruction in class XMLWriterBase
        Parameters:
        target - the target of the processing instruction, may not be null
        text - the data contained in the processing instruction, may not be null
        Throws:
        javax.xml.stream.XMLStreamException
      • writeDTD

        public void writeDTD​(java.lang.String dtd)
                      throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Write a DTD section. This string represents the entire doctypedecl production from the XML 1.0 specification.
        Specified by:
        writeDTD in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeDTD in class XMLWriterBase
        Parameters:
        dtd - the DTD to be written
        Throws:
        javax.xml.stream.XMLStreamException
      • writeCData

        public void writeCData​(java.lang.String data)
                        throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Writes a CData section
        Specified by:
        writeCData in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeCData in class XMLWriterBase
        Parameters:
        data - the data contained in the CData Section, may not be null
        Throws:
        javax.xml.stream.XMLStreamException
      • writeEntityRef

        public void writeEntityRef​(java.lang.String name)
                            throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Writes an entity reference
        Specified by:
        writeEntityRef in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeEntityRef in class XMLWriterBase
        Parameters:
        name - the name of the entity
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartDocument

        public void writeStartDocument()
                                throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Write the XML Declaration. Defaults the XML version to 1.0, and the encoding to utf-8
        Specified by:
        writeStartDocument in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeStartDocument in class XMLWriterBase
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartDocument

        public void writeStartDocument​(java.lang.String version)
                                throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Write the XML Declaration. Defaults the XML version to 1.0
        Specified by:
        writeStartDocument in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeStartDocument in class XMLWriterBase
        Parameters:
        version - version of the xml document
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartDocument

        public void writeStartDocument​(java.lang.String encoding,
                                       java.lang.String version)
                                throws javax.xml.stream.XMLStreamException
        Description copied from interface: javax.xml.stream.XMLStreamWriter
        Write the XML Declaration. Note that the encoding parameter does not set the actual encoding of the underlying output. That must be set when the instance of the XMLStreamWriter is created using the XMLOutputFactory
        Specified by:
        writeStartDocument in interface javax.xml.stream.XMLStreamWriter
        Overrides:
        writeStartDocument in class XMLWriterBase
        Parameters:
        encoding - encoding of the xml declaration
        version - version of the xml document
        Throws:
        javax.xml.stream.XMLStreamException
      • writeCharactersInternal

        protected void writeCharactersInternal​(char[] characters,
                                               int start,
                                               int length,
                                               boolean isAttributeValue)
                                        throws javax.xml.stream.XMLStreamException
        Overrides:
        writeCharactersInternal in class XMLWriterBase
        Throws:
        javax.xml.stream.XMLStreamException
      • write

        public void write​(javax.xml.stream.XMLStreamReader xmlr)
                   throws javax.xml.stream.XMLStreamException
        Overrides:
        write in class ReaderToWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception