Package org.apache.uima.util

# Class XMLInputSource

java.lang.Object
org.apache.uima.util.XMLInputSource

public class XMLInputSource extends 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.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `XMLInputSource(File aFile)`
  Creates an `XMLInputSource` from a descriptor file.
  `XMLInputSource(InputStream aInputStream)`
  Creates an XMLInputSource from an existing InputStream.
  `XMLInputSource(InputStream aInputStream, File aRelativePathBase)`
  Creates an XMLInputSource from an existing InputStream.
  `XMLInputSource(String aUrlOrFileName)`
  Creates an `XMLInputSource` from a descriptor file.
  `XMLInputSource(URL aURL)`
  Creates an `XMLInputSource` from a URL.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Closes the underlying `InputStream`.
  `InputStream`
  `getInputStream()`
  Gets the InputStream from which to read an XML document.
  `File`
  `getRelativePathBase()`
  Deprecated.
  Use `getURL()` instead.
  `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`

- ## Constructor Details

  - ### XMLInputSource

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

  - ### XMLInputSource

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

  - ### XMLInputSource

    public XMLInputSource(InputStream aInputStream)
    Creates an XMLInputSource from an existing InputStream.
    Parameters:
      `aInputStream` - input stream from which to read

  - ### XMLInputSource

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

  - ### XMLInputSource

    public XMLInputSource(URL aURL) throws IOException
    Creates an `XMLInputSource` from a URL.
    Parameters:
      `aURL` - URL to read from
    Throws:
      `IOException` - if an I/O error occurs

- ## Method Details

  - ### getInputStream

    public 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 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 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 IOException
    Closes the underlying `InputStream`.
    Throws:
      `IOException` - if an I/O error occurs.