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:
        NegativeArraySizeException - If the size argument is less than 0.
    • Method Detail

      • setSystemId

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

        public void createFromXMLStreamReader​(XMLStreamReader reader)
                                       throws 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:
        XMLStreamException
      • createFromXMLStreamWriter

        public 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.

      • 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)