OPEN - issue INT-396: Update documentation on file reading
http://jira.springframework.org/browse/INT-396
This commit is contained in:
@@ -20,6 +20,8 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
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
|
||||
@@ -33,6 +35,7 @@ public abstract class AbstractFileListFilter implements FileListFilter {
|
||||
* Returns the list of files that are accepted by this filter.
|
||||
*/
|
||||
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)) {
|
||||
|
||||
@@ -24,6 +24,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Composition that delegates to multiple {@link FileFilter}s. The composition
|
||||
* is AND based, meaning that a file must pass through each filter's
|
||||
@@ -35,7 +37,6 @@ public class CompositeFileListFilter implements FileListFilter {
|
||||
|
||||
private final Set<FileListFilter> fileFilters;
|
||||
|
||||
|
||||
public CompositeFileListFilter(FileListFilter... fileFilters) {
|
||||
this.fileFilters = new HashSet<FileListFilter>(Arrays.asList(fileFilters));
|
||||
}
|
||||
@@ -44,11 +45,14 @@ public class CompositeFileListFilter implements FileListFilter {
|
||||
this.fileFilters = new HashSet<FileListFilter>(fileFilters);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* This implementation delegates to a collection of filters and returns only files that pass all
|
||||
* the filters.
|
||||
*/
|
||||
public List<File> filterFiles(File[] files) {
|
||||
Assert.notNull(files, "'files' should not be null");
|
||||
List<File> leftOver = Arrays.asList(files);
|
||||
for (FileListFilter fileFilter : fileFilters) {
|
||||
leftOver = fileFilter.filterFiles(leftOver.toArray(new File[] {}));
|
||||
|
||||
@@ -26,6 +26,9 @@ import java.util.List;
|
||||
*/
|
||||
public interface FileListFilter {
|
||||
|
||||
/**
|
||||
* Filters out files and returns the files that are left in a list.
|
||||
*/
|
||||
List<File> filterFiles(File[] files);
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<list>
|
||||
<bean class="org.springframework.integration.file.AcceptOnceFileListFilter" />
|
||||
<bean class="org.springframework.integration.file.TestFileListFilter" />
|
||||
<bean class="org.springframework.integration.file.PatternMatchingFileListFilter">
|
||||
<constructor-arg value="^test.*$"/>
|
||||
</bean>
|
||||
</list>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
Reference in New Issue
Block a user