org.apache.commons.mail.resolver

## Class DataSourceUrlResolver

- java.lang.Object
- - org.apache.commons.mail.resolver.DataSourceBaseResolver
  - - org.apache.commons.mail.resolver.DataSourceUrlResolver

- All Implemented Interfaces:
    DataSourceResolver

      public class DataSourceUrlResolver
      extends DataSourceBaseResolver

  Creates a `DataSource` based on an URL.
  Since:
    1.3

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataSourceUrlResolver(URL baseUrl)` Constructor.
    `DataSourceUrlResolver(URL baseUrl, boolean lenient)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected URL` | `createUrl(String resourceLocation)` Create an URL based on a base URL and a resource location suitable for loading the resource.
    `URL` | `getBaseUrl()` Get the base URL used for resolving relative resource locations.
    `DataSource` | `resolve(String resourceLocation)` Resolves the given resource location to a `DataSource`.
    `DataSource` | `resolve(String resourceLocation, boolean isLenient)` Resolves the given resource location to a `DataSource`.

    - ### Methods inherited from class org.apache.commons.mail.resolver.DataSourceBaseResolver

      `isCid, isFileUrl, isHttpUrl, isLenient`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DataSourceUrlResolver

          public DataSourceUrlResolver(URL baseUrl)

      Constructor.
      Parameters:
        `baseUrl` - the base URL used for resolving relative resource locations

    - #### DataSourceUrlResolver

          public DataSourceUrlResolver(URL baseUrl,
                                       boolean lenient)

      Constructor.
      Parameters:
        `baseUrl` - the base URL used for resolving relative resource locations
        `lenient` - shall we ignore resources not found or complain with an exception

  - ### Method Detail

    - #### getBaseUrl

          public URL getBaseUrl()

      Get the base URL used for resolving relative resource locations.
      Returns:
        the baseUrl

    - #### resolve

          public DataSource resolve(String resourceLocation)
                             throws IOException

      Resolves the given resource location to a `DataSource`.
      Parameters:
        `resourceLocation` - the location of the resource
      Returns:
        the `DataSource`
      Throws:
        `IOException` - the resource was not found

    - #### resolve

          public DataSource resolve(String resourceLocation,
                                    boolean isLenient)
                             throws IOException

      Resolves the given resource location to a `DataSource`.
      Parameters:
        `resourceLocation` - the location of the resource
        `isLenient` - shall we ignore resources not found or complain with an exception?
      Returns:
        the data source containing the resource or null if the resource was not found in lenient mode
      Throws:
        `IOException` - resolving the resource failed

    - #### createUrl

          protected URL createUrl(String resourceLocation)
                           throws MalformedURLException

      Create an URL based on a base URL and a resource location suitable for loading the resource.
      Parameters:
        `resourceLocation` - a resource location
      Returns:
        the corresponding URL
      Throws:
        `MalformedURLException` - creating the URL failed

Copyright © 2001–2017 The Apache Software Foundation. All rights reserved.