Class StreamProvider

  • All Implemented Interfaces:
    Provider

    class StreamProvider
    extends java.lang.Object
    implements Provider
    The StreamProvider object is used to provide event reader implementations for StAX. Wrapping the mechanics of the StAX framework within a Provider ensures that it can be plugged in without any dependencies. This allows other parsers to be swapped in should there be such a requirement.
    See Also:
    StreamProvider
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private javax.xml.stream.XMLInputFactory factory
      This is the factory that is used to create StAX parsers.
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamProvider()
      Constructor for the StreamProvider object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      EventReader provide​(java.io.InputStream source)
      This provides an EventReader that will read from the specified input stream.
      EventReader provide​(java.io.Reader source)
      This provides an EventReader that will read from the specified reader.
      private EventReader provide​(javax.xml.stream.XMLEventReader source)
      This provides an EventReader that will read from the specified reader.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • factory

        private final javax.xml.stream.XMLInputFactory factory
        This is the factory that is used to create StAX parsers.
    • Constructor Detail

      • StreamProvider

        public StreamProvider()
        Constructor for the StreamProvider object. This is used to instantiate a parser factory that will be used to create parsers when requested. Instantiating the factory up front also checks that the framework is fully supported.
    • Method Detail

      • provide

        public EventReader provide​(java.io.InputStream source)
                            throws java.lang.Exception
        This provides an EventReader that will read from the specified input stream. When reading from an input stream the character encoding should be taken from the XML prolog or it should default to the UTF-8 character encoding.
        Specified by:
        provide in interface Provider
        Parameters:
        source - this is the stream to read the document with
        Returns:
        this is used to return the event reader implementation
        Throws:
        java.lang.Exception
      • provide

        public EventReader provide​(java.io.Reader source)
                            throws java.lang.Exception
        This provides an EventReader that will read from the specified reader. When reading from a reader the character encoding should be the same as the source XML document.
        Specified by:
        provide in interface Provider
        Parameters:
        source - this is the reader to read the document with
        Returns:
        this is used to return the event reader implementation
        Throws:
        java.lang.Exception
      • provide

        private EventReader provide​(javax.xml.stream.XMLEventReader source)
                             throws java.lang.Exception
        This provides an EventReader that will read from the specified reader. The returned event reader is basically a wrapper for the provided StAX implementation.
        Parameters:
        source - this is the reader to read the document with
        Returns:
        this is used to return the event reader implementation
        Throws:
        java.lang.Exception