Package org.apache.commons.mail.resolver
Class DataSourcePathResolver
- java.lang.Object
-
- org.apache.commons.mail.resolver.DataSourceBaseResolver
-
- org.apache.commons.mail.resolver.DataSourcePathResolver
-
- All Implemented Interfaces:
DataSourceResolver
public final class DataSourcePathResolver extends DataSourceBaseResolver
Creates aDataSourcebased on aPath. The implementation also resolves file resources.- Since:
- 1.6.0
-
-
Constructor Summary
Constructors Constructor Description DataSourcePathResolver()Constructs a new instance.DataSourcePathResolver(java.nio.file.Path baseDir)Constructs a new instance.DataSourcePathResolver(java.nio.file.Path baseDir, boolean lenient, java.nio.file.OpenOption... options)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.file.PathgetBaseDir()Gets the base directory used for resolving relative resource locations.javax.activation.DataSourceresolve(java.lang.String resourceLocation)Resolves the given resource location to aDataSource.javax.activation.DataSourceresolve(java.lang.String resourceLocation, boolean isLenient)Resolves the given resource location to aDataSource.-
Methods inherited from class org.apache.commons.mail.resolver.DataSourceBaseResolver
isCid, isFileUrl, isHttpUrl, isLenient
-
-
-
-
Constructor Detail
-
DataSourcePathResolver
public DataSourcePathResolver()
Constructs a new instance.
-
DataSourcePathResolver
public DataSourcePathResolver(java.nio.file.Path baseDir)
Constructs a new instance.- Parameters:
baseDir- the base directory of the resource when resolving relative paths
-
DataSourcePathResolver
public DataSourcePathResolver(java.nio.file.Path baseDir, boolean lenient, java.nio.file.OpenOption... options)
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 Detail
-
getBaseDir
public java.nio.file.Path getBaseDir()
Gets the base directory used for resolving relative resource locations.- Returns:
- the baseUrl
-
resolve
public javax.activation.DataSource resolve(java.lang.String resourceLocation) throws java.io.IOException
Resolves the given resource location to aDataSource.- Parameters:
resourceLocation- the location of the resource- Returns:
- the
DataSource - Throws:
java.io.IOException- the resource was not found
-
resolve
public javax.activation.DataSource resolve(java.lang.String resourceLocation, boolean isLenient) throws java.io.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:
java.io.IOException- resolving the resource failed
-
-