org.apache.commons.mail.resolver
Class DataSourceFileResolver

java.lang.Object
  extended by org.apache.commons.mail.resolver.DataSourceBaseResolver
      extended by org.apache.commons.mail.resolver.DataSourceFileResolver
All Implemented Interfaces:
DataSourceResolver

public class DataSourceFileResolver
extends DataSourceBaseResolver

Creates a DataSource based on an URL. The implementation also resolves file resources.

Since:
1.3
Version:
$Id: DataSourceFileResolver.java 1420381 2012-12-11 20:18:05Z tn $

Constructor Summary
DataSourceFileResolver()
          Constructor.
DataSourceFileResolver(File baseDir)
          Constructor.
DataSourceFileResolver(File baseDir, boolean lenient)
          Constructor.
 
Method Summary
 File getBaseDir()
          Get the base directory 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

DataSourceFileResolver

public DataSourceFileResolver()
Constructor.


DataSourceFileResolver

public DataSourceFileResolver(File baseDir)
Constructor.

Parameters:
baseDir - the base directory of the resource when resolving relative paths

DataSourceFileResolver

public DataSourceFileResolver(File baseDir,
                              boolean lenient)
Constructor.

Parameters:
baseDir - the base directory of the resource when resolving relative paths
lenient - shall we ignore resources not found or complain with an exception
Method Detail

getBaseDir

public File getBaseDir()
Get the base directory 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


Copyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.