Class DataSourcePathResolver
java.lang.Object
org.apache.commons.mail2.jakarta.resolver.DataSourceBaseResolver
org.apache.commons.mail2.jakarta.resolver.DataSourcePathResolver
- All Implemented Interfaces:
DataSourceResolver
Creates a
DataSource
based on a Path
. The implementation also resolves file resources.- Since:
- 1.6.0
-
Constructor Summary
ConstructorDescriptionConstructs a new instance.DataSourcePathResolver
(Path baseDir) Constructs a new instance.DataSourcePathResolver
(Path baseDir, boolean lenient, OpenOption... options) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionGets the base directory used for resolving relative resource locations.jakarta.activation.DataSource
Resolves the given resource location to aDataSource
.jakarta.activation.DataSource
Resolves the given resource location to aDataSource
.Methods inherited from class org.apache.commons.mail2.jakarta.resolver.DataSourceBaseResolver
isCid, isFileUrl, isHttpUrl, isLenient
-
Constructor Details
-
DataSourcePathResolver
public DataSourcePathResolver()Constructs a new instance. -
DataSourcePathResolver
Constructs a new instance.- Parameters:
baseDir
- the base directory of the resource when resolving relative paths
-
DataSourcePathResolver
Constructs a new instance.- Parameters:
baseDir
- the base directory of the resource when resolving relative pathslenient
- shall we ignore resources not found or complain with an exceptionoptions
- options for opening streams.
-
-
Method Details
-
getBaseDir
Gets the base directory 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
public jakarta.activation.DataSource resolve(String resourceLocation, boolean isLenient) throws IOException 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
-