Class MutableXMLStreamBuffer

java.lang.Object
com.sun.xml.stream.buffer.XMLStreamBuffer
com.sun.xml.stream.buffer.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 Details

    • 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:
  • Constructor Details

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

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

    • 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(XMLReader reader, InputStream in) throws SAXException, 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:
      SAXException
      IOException
    • createFromXMLReader

      public void createFromXMLReader(XMLReader reader, InputStream in, String systemId) throws SAXException, 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:
      SAXException
      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)