Class MutableXMLStreamBuffer


  • public class MutableXMLStreamBuffer
    extends XMLStreamBuffer
    A mutable stream-based buffer of an XML infoset.

    A MutableXMLStreamBuffer is created using specific SAX and StAX-based creators. Utility methods on MutableXMLStreamBuffer are provided for such functionality that utilize SAX and StAX-based creators.

    Once instantiated the same instance of a MutableXMLStreamBuffer may be reused for creation to reduce the amount of Objects instantiated and garbage collected that are required for internally representing an XML infoset.

    A MutableXMLStreamBuffer is not designed to be created and processed concurrently. If done so unspecified behaviour may occur.

    • Field Detail

      • DEFAULT_ARRAY_SIZE

        public static final int DEFAULT_ARRAY_SIZE
        The default array size for the arrays used in internal representation of the XML infoset.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MutableXMLStreamBuffer

        public MutableXMLStreamBuffer()
        Create a new MutableXMLStreamBuffer using the DEFAULT_ARRAY_SIZE.
      • MutableXMLStreamBuffer

        public MutableXMLStreamBuffer​(int size)
        Create a new MutableXMLStreamBuffer.
        Parameters:
        size - The size of the arrays used in the internal representation of the XML infoset.
        Throws:
        java.lang.NegativeArraySizeException - If the size argument is less than 0.
    • Method Detail

      • setSystemId

        public void setSystemId​(java.lang.String systemId)
        Set the system identifier for this buffer.
        Parameters:
        systemId - The system identifier.
      • createFromXMLStreamReader

        public void createFromXMLStreamReader​(javax.xml.stream.XMLStreamReader reader)
                                       throws javax.xml.stream.XMLStreamException
        Create contents of a buffer from a XMLStreamReader.

        The MutableXMLStreamBuffer is reset (see reset()) before creation.

        The MutableXMLStreamBuffer is created by consuming the events on the XMLStreamReader using an instance of StreamReaderBufferCreator.

        Parameters:
        reader - A XMLStreamReader to read from to create.
        Throws:
        javax.xml.stream.XMLStreamException
      • createFromXMLStreamWriter

        public javax.xml.stream.XMLStreamWriter createFromXMLStreamWriter()
        Create contents of a buffer from a XMLStreamWriter.

        The MutableXMLStreamBuffer is reset (see reset()) before creation.

        The MutableXMLStreamBuffer is created by consuming events on a XMLStreamWriter using an instance of StreamWriterBufferCreator.

      • createFromSAXBufferCreator

        public SAXBufferCreator createFromSAXBufferCreator()
        Create contents of a buffer from a SAXBufferCreator.

        The MutableXMLStreamBuffer is reset (see reset()) before creation.

        The MutableXMLStreamBuffer is created by consuming events from a ContentHandler using an instance of SAXBufferCreator.

        Returns:
        The SAXBufferCreator to create from.
      • createFromXMLReader

        public void createFromXMLReader​(org.xml.sax.XMLReader reader,
                                        java.io.InputStream in)
                                 throws org.xml.sax.SAXException,
                                        java.io.IOException
        Create contents of a buffer from a XMLReader and InputStream.

        The MutableXMLStreamBuffer is reset (see reset()) before creation.

        The MutableXMLStreamBuffer is created by using an instance of SAXBufferCreator and registering associated handlers on the XMLReader.

        Parameters:
        reader - The XMLReader to use for parsing.
        in - The InputStream to be parsed.
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • createFromXMLReader

        public void createFromXMLReader​(org.xml.sax.XMLReader reader,
                                        java.io.InputStream in,
                                        java.lang.String systemId)
                                 throws org.xml.sax.SAXException,
                                        java.io.IOException
        Create contents of a buffer from a XMLReader and InputStream.

        The MutableXMLStreamBuffer is reset (see reset()) before creation.

        The MutableXMLStreamBuffer is created by using an instance of SAXBufferCreator and registering associated handlers on the XMLReader.

        Parameters:
        reader - The XMLReader to use for parsing.
        in - The InputStream to be parsed.
        systemId - The system ID of the input stream.
        Throws:
        org.xml.sax.SAXException
        java.io.IOException
      • reset

        public void reset()
        Reset the MutableXMLStreamBuffer.

        This method will reset the MutableXMLStreamBuffer to a state of being "uncreated" similar to the state of a newly instantiated MutableXMLStreamBuffer.

        As many Objects as possible will be retained for reuse in future creation.

      • setHasInternedStrings

        protected void setHasInternedStrings​(boolean hasInternedStrings)