Cosmetic / javadoc on FileListFilters

This commit is contained in:
Iwein Fuld
2008-09-11 17:01:38 +00:00
parent 280da19191
commit 78d349df75
3 changed files with 22 additions and 3 deletions

View File

@@ -6,20 +6,41 @@ import java.util.List;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
/**
* {@link FileListFilter} that passes files only one time. This can conveniently
* be used to prevent duplication of files, as is done in
* {@link PollableFileSource}
*
* @author Iwein Fuld
*
*/
public class AcceptOnceFileFilter implements FileListFilter {
private final Queue<File> seen;
private final Object monitor = new Object();
/**
* Creates an AcceptOnceFileFilter that is based on a bounded queue. If the
* queue overflows files that fall out will be pass this filter again if
* passed to the {@link #filterFiles(File[])} method
* @param maxCapacity
*/
public AcceptOnceFileFilter(int maxCapacity) {
seen = new LinkedBlockingQueue<File>(maxCapacity);
}
/**
* Creates an AcceptOnceFileFilter based on an unbounded queue
*/
public AcceptOnceFileFilter() {
seen = new LinkedBlockingQueue<File>();
}
/**
* Returns the list of files that have not been filtered by this instance
* before
*/
public List<File> filterFiles(File[] files) {
List<File> accepted = new ArrayList<File>();
for (File file : files) {
@@ -42,5 +63,4 @@ public class AcceptOnceFileFilter implements FileListFilter {
return false;
}
}
}

View File

@@ -24,7 +24,7 @@ import java.util.List;
import java.util.Set;
/**
* Composition that delegates to multiple {@link FileFilter}s. The compostition
* Composition that delegates to multiple {@link FileFilter}s. The composition
* is AND based, meaning that all filters must {@link #filterFiles(File)} in
* order for a file to be accepted by the composite.
*

View File

@@ -22,7 +22,6 @@ import static org.junit.Assert.assertNull;
import java.io.File;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicLong;
import org.junit.After;
import org.junit.AfterClass;