commons-email2-jakarta/src/main/java/org/apache/commons/mail2/jakarta/resolver/DataSourceFileResolver.java [30:97]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class DataSourceFileResolver extends DataSourceBaseResolver {

    /** The base directory of the resource when resolving relative paths */
    private final File baseDir;

    /**
     * Constructs a new instance.
     */
    public DataSourceFileResolver() {
        baseDir = new File(".");
    }

    /**
     * Constructs a new instance.
     *
     * @param baseDir the base directory of the resource when resolving relative paths
     */
    public DataSourceFileResolver(final File baseDir) {
        this.baseDir = baseDir;
    }

    /**
     * Constructs a new instance.
     *
     * @param baseDir the base directory of the resource when resolving relative paths
     * @param lenient shall we ignore resources not found or complain with an exception
     */
    public DataSourceFileResolver(final File baseDir, final boolean lenient) {
        super(lenient);
        this.baseDir = baseDir;
    }

    /**
     * Gets the base directory used for resolving relative resource locations.
     *
     * @return the baseUrl
     */
    public File getBaseDir() {
        return baseDir;
    }

    /** {@inheritDoc} */
    @Override
    public DataSource resolve(final String resourceLocation) throws IOException {
        return resolve(resourceLocation, isLenient());
    }

    /** {@inheritDoc} */
    @Override
    public DataSource resolve(final String resourceLocation, final boolean isLenient) throws IOException {
        File file;
        DataSource result = null;

        if (!isCid(resourceLocation)) {
            file = new File(resourceLocation);

            if (!file.isAbsolute()) {
                file = getBaseDir() != null ? new File(getBaseDir(), resourceLocation) : new File(resourceLocation);
            }

            if (file.exists()) {
                result = new FileDataSource(file);
            } else if (!isLenient) {
                throw new IOException("Cant resolve the following file resource :" + file.getAbsolutePath());
            }
        }

        return result;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



commons-email2-javax/src/main/java/org/apache/commons/mail2/javax/resolver/DataSourceFileResolver.java [30:97]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class DataSourceFileResolver extends DataSourceBaseResolver {

    /** The base directory of the resource when resolving relative paths */
    private final File baseDir;

    /**
     * Constructs a new instance.
     */
    public DataSourceFileResolver() {
        baseDir = new File(".");
    }

    /**
     * Constructs a new instance.
     *
     * @param baseDir the base directory of the resource when resolving relative paths
     */
    public DataSourceFileResolver(final File baseDir) {
        this.baseDir = baseDir;
    }

    /**
     * Constructs a new instance.
     *
     * @param baseDir the base directory of the resource when resolving relative paths
     * @param lenient shall we ignore resources not found or complain with an exception
     */
    public DataSourceFileResolver(final File baseDir, final boolean lenient) {
        super(lenient);
        this.baseDir = baseDir;
    }

    /**
     * Gets the base directory used for resolving relative resource locations.
     *
     * @return the baseUrl
     */
    public File getBaseDir() {
        return baseDir;
    }

    /** {@inheritDoc} */
    @Override
    public DataSource resolve(final String resourceLocation) throws IOException {
        return resolve(resourceLocation, isLenient());
    }

    /** {@inheritDoc} */
    @Override
    public DataSource resolve(final String resourceLocation, final boolean isLenient) throws IOException {
        File file;
        DataSource result = null;

        if (!isCid(resourceLocation)) {
            file = new File(resourceLocation);

            if (!file.isAbsolute()) {
                file = getBaseDir() != null ? new File(getBaseDir(), resourceLocation) : new File(resourceLocation);
            }

            if (file.exists()) {
                result = new FileDataSource(file);
            } else if (!isLenient) {
                throw new IOException("Cant resolve the following file resource :" + file.getAbsolutePath());
            }
        }

        return result;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



