IN PROGRESS - issue INT-546: FileListFilters throw an IllegalArgumentException when the polled directory is empty

http://jira.springframework.org/browse/INT-546
This commit is contained in:
Iwein Fuld
2009-01-08 19:58:34 +00:00
parent d040d689a4
commit b81edbddaf
5 changed files with 138 additions and 8 deletions

View File

@@ -23,23 +23,25 @@ import java.util.List;
import org.springframework.util.Assert;
/**
* A convenience base class for any {@link FileListFilter} whose criteria can
* be evaluated against each File in isolation. If the entire List of files is
* A convenience base class for any {@link FileListFilter} whose criteria can be
* evaluated against each File in isolation. If the entire List of files is
* required for evaluation, implement the FileListFilter interface directly.
*
* @author Mark Fisher
* @author Iwein Fuld
*/
public abstract class AbstractFileListFilter implements FileListFilter {
/**
* Returns the list of files that are accepted by this filter.
* {@inheritDoc}
*/
public final List<File> filterFiles(File[] files) {
Assert.notNull(files,"'files' should not be null.");
List<File> accepted = new ArrayList<File>();
for (File file : files) {
if (this.accept(file)) {
accepted.add(file);
if (files != null) {
for (File file : files) {
if (this.accept(file)) {
accepted.add(file);
}
}
}
return accepted;

View File

@@ -27,7 +27,8 @@ import java.util.List;
public interface FileListFilter {
/**
* Filters out files and returns the files that are left in a list.
* Filters out files and returns the files that are left in a list, or an
* empty list when a null is passed in.
*/
List<File> filterFiles(File[] files);