Class DataSourceUrlResolver
java.lang.Object
org.apache.commons.mail2.javax.resolver.DataSourceBaseResolver
org.apache.commons.mail2.javax.resolver.DataSourceUrlResolver
- All Implemented Interfaces:
DataSourceResolver
Creates a
DataSource
based on an URL.- Since:
- 1.3
-
Constructor Summary
ConstructorDescriptionDataSourceUrlResolver
(URL baseUrl) Constructs a new instance.DataSourceUrlResolver
(URL baseUrl, boolean lenient) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected URL
Create an URL based on a base URL and a resource location suitable for loading the resource.Gets the base URL used for resolving relative resource locations.Resolves the given resource location to aDataSource
.Resolves the given resource location to aDataSource
.Methods inherited from class org.apache.commons.mail2.javax.resolver.DataSourceBaseResolver
isCid, isFileUrl, isHttpUrl, isLenient
-
Constructor Details
-
DataSourceUrlResolver
Constructs a new instance.- Parameters:
baseUrl
- the base URL used for resolving relative resource locations
-
DataSourceUrlResolver
Constructs a new instance.- Parameters:
baseUrl
- the base URL used for resolving relative resource locationslenient
- shall we ignore resources not found or complain with an exception
-
-
Method Details
-
createUrl
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
-
getBaseUrl
Gets the base URL used for resolving relative resource locations.- Returns:
- the baseUrl
-
resolve
Resolves the given resource location to aDataSource
.- Parameters:
resourceLocation
- the location of the resource- Returns:
- the
DataSource
- Throws:
IOException
- the resource was not found
-
resolve
Resolves the given resource location to aDataSource
.- Parameters:
resourceLocation
- the location of the resourceisLenient
- 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
-