public abstract class FileVisitor
extends java.lang.Object
Implementation of visitor pattern for scanning all files in some directory.
Modifier and Type | Class and Description |
---|---|
static class |
FileVisitor.Copier |
static class |
FileVisitor.Filtered |
static interface |
FileVisitor.Listable |
static class |
FileVisitor.Lister |
static class |
FileVisitor.Mover |
static class |
FileVisitor.Remover |
Modifier and Type | Field and Description |
---|---|
static int |
DEBUG_LEVEL |
Modifier | Constructor and Description |
---|---|
protected |
FileVisitor(java.io.File root)
Inheritors should call this constructor with the root of the file tree
that should be scanned.
|
Modifier and Type | Method and Description |
---|---|
protected int |
depth() |
boolean |
equals(java.lang.Object obj)
Determines whether or not two objects are equal.
|
void |
execute() |
protected boolean |
executeAlternate() |
boolean |
executeInProgress() |
boolean |
executeWasCalled() |
protected Directory[] |
getLevels() |
int |
hashCode()
Returns the hash code for this object.
|
static void |
main(java.lang.String[] argv) |
protected Directory |
parent()
Returns the current subdirectory that is scanned by this visitor now.
|
static void |
removeOnShutdown(java.io.File f)
This method is an analog of the standard
f.deleteOnExit() :
it plans removing f on the moment before the shutdown
of Java Virtual Machine. |
java.io.File |
root()
Returns the root of file tree that is scanned by this visitor.
|
java.lang.String |
toString()
Returns a string representation of this object.
|
protected abstract void |
visitDirectoryAfter(Directory d,
java.lang.Object savedContext) |
protected abstract java.lang.Object |
visitDirectoryBefore(Directory d) |
protected abstract void |
visitFile(java.io.File f) |
protected void |
visitRootAfter() |
protected FileVisitor(java.io.File root)
root
- the root of file tree that should be scannedjava.lang.NullPointerException
- if the argument is nullpublic final java.io.File root()
protected final Directory parent()
protected final int depth()
protected final Directory[] getLevels()
protected abstract void visitFile(java.io.File f) throws java.io.IOException
java.io.IOException
protected abstract java.lang.Object visitDirectoryBefore(Directory d) throws java.io.IOException
java.io.IOException
protected abstract void visitDirectoryAfter(Directory d, java.lang.Object savedContext) throws java.io.IOException
java.io.IOException
protected void visitRootAfter() throws java.io.IOException
java.io.IOException
protected boolean executeAlternate() throws java.io.IOException
java.io.IOException
public final void execute() throws java.io.IOException
java.io.IOException
public final boolean executeWasCalled()
public final boolean executeInProgress()
public java.lang.String toString()
null
.toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- An object to be compared with this instancetrue
if the argument has the same type FileVisitor and is equal to this instancepublic static void removeOnShutdown(java.io.File f)
f.deleteOnExit()
:
it plans removing f
on the moment before the shutdown
of Java Virtual Machine.
But, unlike that method, this one compeletely removes f
also in a case when it is a directory: then it is removed recursively
including all files and subdirectories.f
- The file or directory that will be removed before JVM shutdownpublic static void main(java.lang.String[] argv)