Class XMLInputSource


  • public class XMLInputSource
    extends java.lang.Object
    An input source used by the XMLParser to read XML documents for parsing.

    The application uses the XMLInputSource(File) constructor to create an XMLInputSource from a descriptor File. Alternatively, if the source of the XML is not a file, the XMLInputSource(InputStream,File) constructor may be used to read the XML from an input stream. The second argument to this constructor is the relative path base, to be used if the descriptor contains imports with relative paths. It is acceptable to set this to null if it is known that the descriptor does not contain any such imports.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.InputStream mInputStream
      InputStream from which the XML document is read.
      private java.net.URL mURL
      URL that we're parsing from
    • Constructor Summary

      Constructors 
      Constructor Description
      XMLInputSource​(java.io.File aFile)
      Creates an XMLInputSource from a descriptor file.
      XMLInputSource​(java.io.InputStream aInputStream, java.io.File aRelativePathBase)
      Creates an XMLInputSource from an existing InputStream.
      XMLInputSource​(java.lang.String aUrlOrFileName)
      Creates an XMLInputSource from a descriptor file.
      XMLInputSource​(java.net.URL aURL)
      Creates an XMLInputSource from a URL.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void close()
      Closes the underlying InputStream.
      java.io.InputStream getInputStream()
      Gets the InputStream from which to read an XML document.
      java.io.File getRelativePathBase()
      Deprecated.
      Use getURL() instead.
      java.net.URL getURL()
      Gets the base for resolving relative paths.
      • Methods inherited from class java.lang.Object

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

      • mInputStream

        private java.io.InputStream mInputStream
        InputStream from which the XML document is read.
      • mURL

        private java.net.URL mURL
        URL that we're parsing from
    • Constructor Detail

      • XMLInputSource

        public XMLInputSource​(java.io.File aFile)
                       throws java.io.IOException
        Creates an XMLInputSource from a descriptor file.
        Parameters:
        aFile - file to read from
        Throws:
        java.io.IOException - if an I/O error occurs
      • XMLInputSource

        public XMLInputSource​(java.lang.String aUrlOrFileName)
                       throws java.io.IOException
        Creates an XMLInputSource from a descriptor file.
        Parameters:
        aUrlOrFileName - a URL or a file name to read from
        Throws:
        java.io.IOException - if an I/O error occurs
      • XMLInputSource

        public XMLInputSource​(java.io.InputStream aInputStream,
                              java.io.File aRelativePathBase)
        Creates an XMLInputSource from an existing InputStream.
        Parameters:
        aInputStream - input stream from which to read
        aRelativePathBase - base for resolving relative paths. This must be a directory.
      • XMLInputSource

        public XMLInputSource​(java.net.URL aURL)
                       throws java.io.IOException
        Creates an XMLInputSource from a URL.
        Parameters:
        aURL - URL to read from
        Throws:
        java.io.IOException - if an I/O error occurs
    • Method Detail

      • getInputStream

        public java.io.InputStream getInputStream()
        Gets the InputStream from which to read an XML document.
        Returns:
        an InputStream from which an XML document may be read
      • getRelativePathBase

        @Deprecated
        public java.io.File getRelativePathBase()
        Deprecated.
        Use getURL() instead.
        Gets the base for resolving relative paths. This must be a directory.
        Returns:
        the base for resolving relative paths, null if none has been specified.
      • getURL

        public java.net.URL getURL()
        Gets the base for resolving relative paths. This must be a directory.
        Returns:
        the base for resolving relative paths, null if none has been specified.
      • close

        public void close()
                   throws java.io.IOException
        Closes the underlying InputStream.
        Throws:
        java.io.IOException - if an I/O error occurs.