|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.hunsicker.io.DirectoryScanner
Class for scanning a directory for files/directories that match a certain filter.
FilenameFilter
,
org.apache.oro.io.RegexFilenameFilter
Constructor Summary | |
DirectoryScanner()
Creates a new DirectoryScanner object. |
|
DirectoryScanner(java.io.File directory)
Creates a new DirectoryScanner object. |
|
DirectoryScanner(java.io.File directory,
int levels)
Creates a new DirectoryScanner object. |
|
DirectoryScanner(java.util.Set directories)
Creates a new DirectoryScanner object. |
|
DirectoryScanner(java.util.Set directories,
int levels)
Creates a new DirectoryScanner object. |
|
DirectoryScanner(java.lang.String directory)
Creates a new DirectoryScanner object. |
|
DirectoryScanner(java.lang.String directory,
int levels)
Creates a new DirectoryScanner object. |
Method Summary | |
void |
addFilter(java.io.FilenameFilter filter)
Adds the given file filter. |
java.io.File[] |
getFiles()
Returns an array with the found files. |
int |
getMaxLevels()
Returns the directory depth (the number of levels) to search. |
boolean |
isEmpty()
Indicates whether the queue with the found files is empty. |
boolean |
isFinished()
Indicates whether the scan has finished or is still running. |
java.util.Iterator |
iterator()
Returns an iterator over the found files. |
java.io.File |
pop()
Returns and removes the file at the top of the internal file queue. |
void |
removeFilter(java.io.FilenameFilter filter)
Removes the given file filter. |
void |
reset()
Resets the scanner so it can be reused. |
void |
run()
Starts the scanning process. |
void |
setFilterPolicy(int policy)
Sets the filter policy to use. |
void |
setMaxLevels(int level)
Sets the directory depth (number of levels) to search. |
void |
setTargets(java.util.Collection targets)
Sets the targets to search (both single files and directories are valid) |
void |
setTargets(java.util.Set targets)
Sets the targets to search. |
java.io.File |
take()
Returns and removes the file at the top of the internal file queue. |
void |
waitUntilFinished()
Blocks until the scanner has finished processing. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DirectoryScanner()
public DirectoryScanner(java.lang.String directory)
directory
- directory to scan.public DirectoryScanner(java.lang.String directory, int levels)
directory
- directory to scan.levels
- number of levels to scan.public DirectoryScanner(java.io.File directory)
directory
- directory to scan.public DirectoryScanner(java.io.File directory, int levels)
directory
- directory to scan.levels
- number of levels to scan.public DirectoryScanner(java.util.Set directories)
directories
- directories to scan.public DirectoryScanner(java.util.Set directories, int levels)
directories
- directories to scan.levels
- number of levels to scan.Method Detail |
public boolean isEmpty()
true
if the queue is empty.public java.io.File[] getFiles()
public void setFilterPolicy(int policy)
policy
- valid filter policy.public boolean isFinished()
true
if the scan has finished.public void setMaxLevels(int level)
level
- directory depth to search.
java.lang.IllegalStateException
- if the scanner hasn't finished processing yet
(isFinished() == true
)isFinished()
public int getMaxLevels()
public void setTargets(java.util.Collection targets)
targets
- collection with the targets to search.public void setTargets(java.util.Set targets)
targets
- set with the targets to search.
java.lang.NullPointerException
- if targets == null
java.lang.IllegalStateException
- if the scanner hasn't finished processing yet
(isFinished() == true
)public void addFilter(java.io.FilenameFilter filter)
filter
- file filter to add.
java.lang.IllegalStateException
- if the scanner hasn't finished processing yet
(isFinished() == true
)public java.util.Iterator iterator()
public java.io.File pop()
isEmpty()
,
take()
public void removeFilter(java.io.FilenameFilter filter)
filter
- file filter to remove.
java.lang.IllegalStateException
- if the scanner hasn't finished processing yet
(isFinished() == true
)public void reset()
public void run()
pop()
or take()
calls.
run
in interface java.lang.Runnable
public java.io.File take() throws java.lang.InterruptedException
pop()
.
java.lang.InterruptedException
- if the queue contains no elements.pop()
public void waitUntilFinished()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |