diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AbstractEntryListFilter.java b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AbstractEntryListFilter.java index 87239b84b2..7de94a91cb 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AbstractEntryListFilter.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AbstractEntryListFilter.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.List; - /** * A convenience base class for any {@link EntryListFilter} whose criteria can be * evaluated against each File in isolation. If the entire List of files is @@ -29,26 +28,26 @@ import java.util.List; * * @author Mark Fisher * @author Iwein Fuld - * @author Josh Long + * @author Josh Long */ public abstract class AbstractEntryListFilter implements InitializingBean, EntryListFilter { - public abstract boolean accept(T t); + public abstract boolean accept(T t); - public List filterEntries(T[] entries) { - List accepted = new ArrayList(); + public List filterEntries(T[] entries) { + List accepted = new ArrayList(); - if (entries != null) { - for (T t : entries) { - if (this.accept(t)) { - accepted.add(t); - } - } - } + if (entries != null) { + for (T t : entries) { + if (this.accept(t)) { + accepted.add(t); + } + } + } - return accepted; - } + return accepted; + } - public void afterPropertiesSet() throws Exception { - // its all you! - } + public void afterPropertiesSet() throws Exception { + // its all you! + } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AcceptAllEntryListFilter.java b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AcceptAllEntryListFilter.java index 87cbe8d847..735caee080 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AcceptAllEntryListFilter.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AcceptAllEntryListFilter.java @@ -18,15 +18,15 @@ package org.springframework.integration.file.entries; /** - * Simple NOOP implementation for {@link org.springframework.integration.file.entries.EntryListFilter} implementation. + * Simple NOOP implementation for {@link org.springframework.integration.file.entries.EntryListFilter} implementation. * Suitable as a default in implementations. * * @author Josh Long * @param */ public class AcceptAllEntryListFilter extends AbstractEntryListFilter { - @Override - public boolean accept(T t) { - return true; - } + @Override + public boolean accept(T t) { + return true; + } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AcceptOnceEntryFileListFilter.java b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AcceptOnceEntryFileListFilter.java index cc37ee7197..25af970353 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AcceptOnceEntryFileListFilter.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/AcceptOnceEntryFileListFilter.java @@ -19,7 +19,6 @@ import java.util.Queue; import java.util.concurrent.LinkedBlockingQueue; - /** * {@link EntryListFilter} that passes files only one time. This can * conveniently be used to prevent duplication of files, as is done in @@ -29,42 +28,42 @@ import java.util.concurrent.LinkedBlockingQueue; * * @author Iwein Fuld * @since 1.0.0 - */ + */ public class AcceptOnceEntryFileListFilter extends AbstractEntryListFilter { - private final Queue seen; - private final Object monitor = new Object(); + private final Queue seen; + private final Object monitor = new Object(); - /** - * Creates an {@link org.springframework.integration.file.entries.AcceptOnceEntryFileListFilter} that is based on a bounded queue. If the - * queue overflows, files that fall out will be passed through this filter - * again if passed to the {@link #filterEntries(Object[])} method. - * - * @param maxCapacity the maximum number of Files to maintain in the 'seen' - * queue. - */ - public AcceptOnceEntryFileListFilter(int maxCapacity) { - this.seen = new LinkedBlockingQueue(maxCapacity); - } + /** + * Creates an {@link org.springframework.integration.file.entries.AcceptOnceEntryFileListFilter} that is based on a bounded queue. If the + * queue overflows, files that fall out will be passed through this filter + * again if passed to the {@link #filterEntries(Object[])} method. + * + * @param maxCapacity the maximum number of Files to maintain in the 'seen' + * queue. + */ + public AcceptOnceEntryFileListFilter(int maxCapacity) { + this.seen = new LinkedBlockingQueue(maxCapacity); + } - /** - * Creates an AcceptOnceFileFilter based on an unbounded queue. - */ - public AcceptOnceEntryFileListFilter() { - this.seen = new LinkedBlockingQueue(); - } + /** + * Creates an AcceptOnceFileFilter based on an unbounded queue. + */ + public AcceptOnceEntryFileListFilter() { + this.seen = new LinkedBlockingQueue(); + } - public boolean accept(T pathname) { - synchronized (this.monitor) { - if (seen.contains(pathname)) { - return false; - } + public boolean accept(T pathname) { + synchronized (this.monitor) { + if (seen.contains(pathname)) { + return false; + } - if (!seen.offer(pathname)) { - seen.poll(); - seen.add(pathname); - } + if (!seen.offer(pathname)) { + seen.poll(); + seen.add(pathname); + } - return true; - } - } + return true; + } + } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/CompositeEntryListFilter.java b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/CompositeEntryListFilter.java index 117a1649d3..4321610e80 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/CompositeEntryListFilter.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/CompositeEntryListFilter.java @@ -22,64 +22,64 @@ import java.util.*; public class CompositeEntryListFilter implements EntryListFilter { - private final Set> fileFilters; + private final Set> fileFilters; - public CompositeEntryListFilter() { - this.fileFilters = new LinkedHashSet>(); - } + public CompositeEntryListFilter() { + this.fileFilters = new LinkedHashSet>(); + } - public CompositeEntryListFilter(Collection> fileFilters) { - this.fileFilters = new LinkedHashSet>(fileFilters); - } + public CompositeEntryListFilter(Collection> fileFilters) { + this.fileFilters = new LinkedHashSet>(fileFilters); + } - @SuppressWarnings("unchecked") - public List filterEntries(T[] entries) { - Assert.notNull(entries, "'files' should not be null"); + @SuppressWarnings("unchecked") + public List filterEntries(T[] entries) { + Assert.notNull(entries, "'files' should not be null"); - List leftOver = Arrays.asList(entries); + List leftOver = Arrays.asList(entries); - for (EntryListFilter fileFilter : this.fileFilters) { - T[] ts = (T[]) leftOver.toArray(); - leftOver = fileFilter.filterEntries(ts); - } + for (EntryListFilter fileFilter : this.fileFilters) { + T[] ts = (T[]) leftOver.toArray(); + leftOver = fileFilter.filterEntries(ts); + } - return leftOver; - } + return leftOver; + } - public CompositeEntryListFilter addFilter(EntryListFilter filter) { - return this.addFilters(Arrays.asList(filter)); - } + public CompositeEntryListFilter addFilter(EntryListFilter filter) { + return this.addFilters(Arrays.asList(filter)); + } - /** - * @param filters one or more new filters to add - * @return this CompositeFileFilter instance with the added filters - * @see #addFilters(Collection) - */ - @SuppressWarnings("unused") - public CompositeEntryListFilter addFilters(EntryListFilter[] filters) { - return addFilters(Arrays.asList(filters)); - } + /** + * @param filters one or more new filters to add + * @return this CompositeFileFilter instance with the added filters + * @see #addFilters(Collection) + */ + @SuppressWarnings("unused") + public CompositeEntryListFilter addFilters(EntryListFilter[] filters) { + return addFilters(Arrays.asList(filters)); + } - /** - * Not thread safe. Only a single thread may add filters at a time. - *

- * Add the new filters to this CompositeFileFilter while maintaining the existing filters. - * - * @param filtersToAdd a list of filters to add - * @return this CompositeEntryListFilter instance with the added filters - */ - public CompositeEntryListFilter addFilters(Collection> filtersToAdd) { - for (EntryListFilter elf : filtersToAdd) - if (elf instanceof InitializingBean) { - try { - ((InitializingBean) elf).afterPropertiesSet(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + /** + * Not thread safe. Only a single thread may add filters at a time. + *

+ * Add the new filters to this CompositeFileFilter while maintaining the existing filters. + * + * @param filtersToAdd a list of filters to add + * @return this CompositeEntryListFilter instance with the added filters + */ + public CompositeEntryListFilter addFilters(Collection> filtersToAdd) { + for (EntryListFilter elf : filtersToAdd) + if (elf instanceof InitializingBean) { + try { + ((InitializingBean) elf).afterPropertiesSet(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - this.fileFilters.addAll(filtersToAdd); + this.fileFilters.addAll(filtersToAdd); - return this; - } + return this; + } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/EntryListFilter.java b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/EntryListFilter.java index 076fca83a8..20dca2c18d 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/EntryListFilter.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/EntryListFilter.java @@ -32,5 +32,5 @@ import java.util.List; * @since 1.0.0 */ public interface EntryListFilter { - List filterEntries(T[] entries); + List filterEntries(T[] entries); } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/EntryNamer.java b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/EntryNamer.java index bc32b29e19..4610f90157 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/EntryNamer.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/EntryNamer.java @@ -17,19 +17,18 @@ package org.springframework.integration.file.entries; /** * Responsible for coercing a String identification out of the T entry. - * @param the type of entry (there's an implementation for FTP, SFTP, and plain-old java.io.Files) * * @author Josh Long + * @param the type of entry (there's an implementation for FTP, SFTP, and plain-old java.io.Files) */ public interface EntryNamer { - /** - * This is the one place I couldn't spackle over the interface differences between an FTPFile (FTP adapter), File (File adapter), and LsEntry (SFTP adapter) - * with generics alone. So we have a typed strategy implementation for accessing a property .... - * - * - * @param entry the entry in a file system listing - * @return the String name that might be used to reference that entry or to do regular expression checks against - */ - String nameOf(T entry); + /** + * This is the one place I couldn't spackle over the interface differences between an FTPFile (FTP adapter), File (File adapter), and LsEntry (SFTP adapter) + * with generics alone. So we have a typed strategy implementation for accessing a property .... + * + * @param entry the entry in a file system listing + * @return the String name that might be used to reference that entry or to do regular expression checks against + */ + String nameOf(T entry); } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/FileEntryNamer.java b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/FileEntryNamer.java index 23de52ac76..3417cb7149 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/FileEntryNamer.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/FileEntryNamer.java @@ -21,14 +21,13 @@ import java.io.File; /** * {@link java.io.File} implementation of the {@link org.springframework.integration.file.entries.EntryNamer} strategy. - * + *

* This part feels a little over-engineered... * * @author Josh Long - * */ public class FileEntryNamer implements EntryNamer { - public String nameOf(File entry) { - return (entry != null) ? entry.getName() : null; - } + public String nameOf(File entry) { + return (entry != null) ? entry.getName() : null; + } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/PatternMatchingEntryListFilter.java b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/PatternMatchingEntryListFilter.java index 1e29c1d2cb..590748618a 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/PatternMatchingEntryListFilter.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/PatternMatchingEntryListFilter.java @@ -16,7 +16,6 @@ package org.springframework.integration.file.entries; import org.springframework.beans.factory.InitializingBean; - import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -33,42 +32,42 @@ import java.util.regex.Pattern; * @param the type of entry */ public class PatternMatchingEntryListFilter extends AbstractEntryListFilter implements InitializingBean { - private Pattern pattern; - private String patternExpression; - private EntryNamer entryNamer; + private Pattern pattern; + private String patternExpression; + private EntryNamer entryNamer; - public PatternMatchingEntryListFilter(EntryNamer en, String p) { - this.entryNamer = en; - this.patternExpression = p; - } + public PatternMatchingEntryListFilter(EntryNamer en, String p) { + this.entryNamer = en; + this.patternExpression = p; + } - public PatternMatchingEntryListFilter(EntryNamer en, Pattern p) { - this.entryNamer = en; - this.pattern = p; - } + public PatternMatchingEntryListFilter(EntryNamer en, Pattern p) { + this.entryNamer = en; + this.pattern = p; + } - public void setPattern(Pattern pattern) { - this.pattern = pattern; - } + public void setPattern(Pattern pattern) { + this.pattern = pattern; + } - public void setPatternExpression(String patternExpression) { - this.patternExpression = patternExpression; - } + public void setPatternExpression(String patternExpression) { + this.patternExpression = patternExpression; + } - public void afterPropertiesSet() throws Exception { - if (StringUtils.hasText(this.patternExpression) && (pattern == null)) { - this.pattern = Pattern.compile(this.patternExpression); - } - Assert.notNull(this.entryNamer, "'entryNamer' must not be null!"); - Assert.notNull(this.pattern, "'pattern' mustn't be null!"); - } - - @Override - public boolean accept(T t) { - return (t != null) && this.pattern.matcher(this.entryNamer.nameOf(t)).matches(); - } + public void afterPropertiesSet() throws Exception { + if (StringUtils.hasText(this.patternExpression) && (pattern == null)) { + this.pattern = Pattern.compile(this.patternExpression); + } + Assert.notNull(this.entryNamer, "'entryNamer' must not be null!"); + Assert.notNull(this.pattern, "'pattern' mustn't be null!"); + } - public void setEntryNamer(EntryNamer entryNamer) { - this.entryNamer = entryNamer; - } + @Override + public boolean accept(T t) { + return (t != null) && this.pattern.matcher(this.entryNamer.nameOf(t)).matches(); + } + + public void setEntryNamer(EntryNamer entryNamer) { + this.entryNamer = entryNamer; + } } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/SingleEntryAdaptingEntryListFilter.java b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/SingleEntryAdaptingEntryListFilter.java index 0842b6e027..5aadb3e9d1 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/entries/SingleEntryAdaptingEntryListFilter.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/entries/SingleEntryAdaptingEntryListFilter.java @@ -27,20 +27,20 @@ import org.springframework.util.Assert; */ public class SingleEntryAdaptingEntryListFilter extends AbstractEntryListFilter { - /** - * the {@link org.springframework.integration.file.entries.EntryListFilter} that you'd like to delegate to - */ - private volatile EntryListFilter entryFilter; + /** + * the {@link org.springframework.integration.file.entries.EntryListFilter} that you'd like to delegate to + */ + private volatile EntryListFilter entryFilter; - public SingleEntryAdaptingEntryListFilter(EntryListFilter ef) { - this.entryFilter = ef; - Assert.notNull(this.entryFilter, "the entryFilter can't be null"); - } + public SingleEntryAdaptingEntryListFilter(EntryListFilter ef) { + this.entryFilter = ef; + Assert.notNull(this.entryFilter, "the entryFilter can't be null"); + } - @Override - @SuppressWarnings("unchecked") - public boolean accept(T t) { - T[] ts = (T[]) new Object[] { t }; - return this.entryFilter.filterEntries(ts).size() == 1; - } + @Override + @SuppressWarnings("unchecked") + public boolean accept(T t) { + T[] ts = (T[]) new Object[]{t}; + return this.entryFilter.filterEntries(ts).size() == 1; + } }