Class StreamReaderBufferCreator


public class StreamReaderBufferCreator extends StreamBufferCreator
Create a buffer using an XMLStreamReader.

TODO: Implement the marking the stream on the element when an ID attribute on the element is defined

  • Field Details

    • _eventType

      private int _eventType
    • _storeInScopeNamespacesOnElementFragment

      private boolean _storeInScopeNamespacesOnElementFragment
    • _inScopePrefixes

      private Map<String,Integer> _inScopePrefixes
  • Constructor Details

    • StreamReaderBufferCreator

      public StreamReaderBufferCreator()
      Create a stream reader buffer creator.

      A stream buffer will be created for storing the infoset from a stream reader.

    • StreamReaderBufferCreator

      public StreamReaderBufferCreator(MutableXMLStreamBuffer buffer)
      Create a stream reader buffer creator using a mutable stream buffer.

      Parameters:
      buffer - the mutable stream buffer.
  • Method Details

    • create

      Create the buffer from a stream reader.

      The stream reader must be positioned at the start of the document or the start of an element.

      If the stream is positioned at the start of the document then the whole document is stored and after storing the stream will be positioned at the end of the document.

      If the stream is positioned at the start of an element then the element and all its children will be stored and after storing the stream will be positioned at the next event after the end of the element.

      Returns:
      the mutable stream buffer.
      Throws:
      XMLStreamException - if the stream reader is not positioned at the start of the document or at an element.
    • createElementFragment

      public MutableXMLStreamBuffer createElementFragment(XMLStreamReader reader, boolean storeInScopeNamespaces) throws XMLStreamException
      Creates the buffer from a stream reader that is an element fragment.

      The stream reader will be moved to the position of the next start of an element if the stream reader is not already positioned at the start of an element.

      The element and all its children will be stored and after storing the stream will be positioned at the next event after the end of the element.

      Parameters:
      storeInScopeNamespaces - true if in-scope namespaces of the element fragment should be stored.
      Returns:
      the mutable stream buffer.
      Throws:
      XMLStreamException - if the stream reader cannot be positioned at the start of an element.
    • store

      private void store(XMLStreamReader reader) throws XMLStreamException
      Throws:
      XMLStreamException
    • storeDocumentAndChildren

      private void storeDocumentAndChildren(XMLStreamReader reader) throws XMLStreamException
      Throws:
      XMLStreamException
    • storeElementAndChildren

      private void storeElementAndChildren(XMLStreamReader reader) throws XMLStreamException
      Throws:
      XMLStreamException
    • storeElementAndChildrenEx

      private void storeElementAndChildrenEx(org.jvnet.staxex.XMLStreamReaderEx reader) throws XMLStreamException
      Throws:
      XMLStreamException
    • storeElementAndChildrenNoEx

      private void storeElementAndChildrenNoEx(XMLStreamReader reader) throws XMLStreamException
      Throws:
      XMLStreamException
    • storeElementWithInScopeNamespaces

      private void storeElementWithInScopeNamespaces(XMLStreamReader reader)
    • storeElement

      private void storeElement(XMLStreamReader reader)
    • storeElement

      public void storeElement(String nsURI, String localName, String prefix, String[] ns)
      A low level method a create a structure element explicitly. This is useful when xsb is created from a fragment's XMLStreamReader and inscope namespaces can be passed using this method. Note that there is no way to enumerate namespaces from XMLStreamReader. For e.g: Say the SOAP message is as follows invalid input: '<'S:Envelope xmlns:n1="..">invalid input: '<'S:Body>invalid input: '<'ns2:A> ... when xsb is to be created using a reader that is at invalid input: '<'ns2:A> tag, the inscope namespace like 'n1' can be passed using this method. WARNING: Instead of using this, try other methods(if you don't know what you are doing).
      Parameters:
      ns - an array of the even length of the form { prefix0, uri0, prefix1, uri1, ... }.
    • storeEndElement

      public void storeEndElement()
      A low level method a create a structure element explicitly. This is required to support storeElement(javax.xml.stream.XMLStreamReader) method. WARNING: Instead of using this, try other methods(if you don't know what you are doing).
    • storeNamespaceAttributes

      private void storeNamespaceAttributes(XMLStreamReader reader)
    • storeNamespaceAttributes

      private void storeNamespaceAttributes(String[] ns)
      Parameters:
      ns - an array of the even length of the form { prefix0, uri0, prefix1, uri1, ... }.
    • storeAttributes

      private void storeAttributes(XMLStreamReader reader)
    • storeComment

      private void storeComment(XMLStreamReader reader)
    • storeProcessingInstruction

      private void storeProcessingInstruction(XMLStreamReader reader)