/**
     * The heart of the matter. This is where the selector gets to decide
     * on the inclusion of a file in a particular fileset.
     *
     * @param basedir the base directory the scan is being done from
     * @param filename is the name of the file to check
     * @param file is a PhingFile object the selector can use
     * @return whether the file should be selected or not
     */
    public function isSelected(PhingFile $basedir, $filename, PhingFile $file) {

        $this->validate();

        // Determine file whose out-of-dateness is to be checked
        $destfiles = $this->map->main($filename);

        // If filename does not match the To attribute of the mapper
        // then filter it out of the files we are considering
        if ($destfiles === null) {
            return false;
        }
        // Sanity check
        if (count($destfiles) !== 1 || $destfiles[0] === null) {
            throw new BuildException("Invalid destination file results for " . $this->targetdir . " with filename " . $filename);
        }
        $destname = $destfiles[0];
        $destfile = new PhingFile($this->targetdir, $destname);

        return SelectorUtils::isOutOfDate($file, $destfile, $this->granularity);
    }