use of org.springframework.integration.file.filters.AcceptAllFileListFilter in project spring-integration by spring-projects.
the class FileListFilterFactoryBean method initializeFileListFilter.
private void initializeFileListFilter() {
if (this.result != null) {
return;
}
FileListFilter<File> createdFilter = null;
if ((this.filter != null) && (this.filenamePattern != null || this.filenameRegex != null)) {
throw new IllegalArgumentException("The 'filter' reference is mutually exclusive with " + "either the 'filename-pattern' or 'filename-regex' attribute.");
}
if (this.filenamePattern != null && this.filenameRegex != null) {
throw new IllegalArgumentException("The 'filename-pattern' and 'filename-regex' attributes are mutually exclusive.");
}
final List<FileListFilter<File>> filtersNeeded = new ArrayList<FileListFilter<File>>();
if (!Boolean.FALSE.equals(this.ignoreHidden)) {
filtersNeeded.add(new IgnoreHiddenFileListFilter());
}
// 'filter' is set
if (this.filter != null) {
if (Boolean.TRUE.equals(this.preventDuplicates)) {
filtersNeeded.add(new AcceptOnceFileListFilter<File>());
filtersNeeded.add(this.filter);
} else {
// preventDuplicates is either FALSE or NULL
filtersNeeded.add(this.filter);
}
} else // 'file-pattern' or 'file-regex' is set
if (this.filenamePattern != null || this.filenameRegex != null) {
if (!Boolean.FALSE.equals(this.preventDuplicates)) {
// preventDuplicates is either null or true
filtersNeeded.add(new AcceptOnceFileListFilter<File>());
}
if (this.filenamePattern != null) {
SimplePatternFileListFilter patternFilter = new SimplePatternFileListFilter(this.filenamePattern);
if (this.alwaysAcceptDirectories != null) {
patternFilter.setAlwaysAcceptDirectories(this.alwaysAcceptDirectories);
}
filtersNeeded.add(patternFilter);
}
if (this.filenameRegex != null) {
RegexPatternFileListFilter regexFilter = new RegexPatternFileListFilter(this.filenameRegex);
if (this.alwaysAcceptDirectories != null) {
regexFilter.setAlwaysAcceptDirectories(this.alwaysAcceptDirectories);
}
filtersNeeded.add(regexFilter);
}
} else // no filters are provided
if (Boolean.FALSE.equals(this.preventDuplicates)) {
filtersNeeded.add(new AcceptAllFileListFilter<File>());
} else {
// preventDuplicates is either TRUE or NULL
filtersNeeded.add(new AcceptOnceFileListFilter<File>());
}
if (filtersNeeded.size() == 1) {
createdFilter = filtersNeeded.get(0);
} else {
createdFilter = new CompositeFileListFilter<File>(filtersNeeded);
}
this.result = createdFilter;
}
Aggregations