public class FileLister
extends java.lang.Object
implements java.lang.Iterable<java.io.File>
Constructor and Description |
---|
FileLister(java.util.concurrent.LinkedBlockingQueue<java.io.File> fileQueue) |
FileLister(java.lang.String directory)
Constructor that recursively loads files from the given directory and sets the maximum thread count to the number
of processors available to the Java virtual machine
|
FileLister(java.lang.String directory,
int maxThread)
Constructor that recursively loads files from the given directory and sets the maximum thread count
|
Modifier and Type | Method and Description |
---|---|
int |
fileQueueSize() |
java.io.File |
getDirectory()
Provides the path to the directory used for the initial list of files
|
java.io.File[] |
getFileListerArray() |
java.util.ArrayList<java.io.File> |
getFileListerList() |
java.util.concurrent.LinkedBlockingQueue<java.io.File> |
getFileQueue() |
boolean |
getLoaded()
Provides the boolean indicating if all files have been loaded into the linked blocking queue
|
Pair |
getSublists(double dictionarySize,
double sampleSize)
Populates the dictionary and sample lists, waiting for all files to be loaded before randomly assigning files to
one of the lists.
|
java.util.Iterator<java.io.File> |
iterator()
Provides an iterator over the list of all files
|
void |
loadQueue()
Added by EB.
|
boolean |
moreFiles()
Lets a process that is taking files off the linked blocking queue know if there are more
files or not; use to test if there will be any more.
|
void |
putPoison(java.io.File poison)
Adds a file to the end of the queue as a marker for work being done
|
int |
size()
Provides the size of the list of all files
|
java.io.File |
takeFile()
Retrieves and removes the head of the file queue, waiting if necessary until an element becomes available
|
java.lang.String |
toString()
Returns a list of each of the files in this fileLister, each on a separate line
|
public FileLister(java.lang.String directory)
directory
- the string path to the directory to loadpublic FileLister(java.lang.String directory, int maxThread)
directory
- the string path to the directory to loadmaxThread
- the int
maximum threads to use to run this fileListerpublic FileLister(java.util.concurrent.LinkedBlockingQueue<java.io.File> fileQueue)
public java.util.Iterator<java.io.File> iterator()
iterator
in interface java.lang.Iterable<java.io.File>
public int size()
int
number of filespublic int fileQueueSize()
public boolean getLoaded()
public boolean moreFiles()
public java.io.File getDirectory()
public void loadQueue()
public java.io.File takeFile()
public void putPoison(java.io.File poison)
poison
- the file to put at the tail of the file queuepublic java.lang.String toString()
toString
in class java.lang.Object
public java.util.ArrayList<java.io.File> getFileListerList()
public java.io.File[] getFileListerArray()
public java.util.concurrent.LinkedBlockingQueue<java.io.File> getFileQueue()
public Pair getSublists(double dictionarySize, double sampleSize)
dictionarySize
- the double
number of files to include in the dictionary listsampleSize
- the double
number of files to include in the sample list