protected class FileAccessorLocalJava7.WalkFileTreeVisitor
extends java.lang.Object
implements java.nio.file.FileVisitor<java.nio.file.Path>
FileRemoteWalkerCallback
callback interface.
The callback FileRemoteWalkerCallback#offerLeafNode(FileRemote)
and FileRemoteWalkerCallback#offerParentNode(FileRemote)
is processed only for selected files and directories,
see 4. and 5. parameter of WalkFileTreeVisitor#WalkFileTreeVisitor(FileCluster, boolean, boolean, String, int, FileRemoteWalkerCallback)
FileCluster
.
If any parent of this file will be found in the FileCluster the FileRemote is stored in the FileRemote.children()
.
The FileRemote instance is refreshed with the information from the file on the operation system. The FileRemote.getParent()
is set
and the instance is added as child of the parent. Anyway the same instance of FileRemote is used for the same file path.
Therefore the FileRemote instance can be used to mark something on this file for this application.Modifier and Type | Field and Description |
---|---|
(package private) boolean |
bRefresh |
(package private) FileRemoteWalkerCallback |
callback |
(package private) FileRemoteCmdEventData |
co |
boolean |
debugOut
Can be used internally to control outputs for debugging (printf).
|
(package private) EventWithDst<FileRemoteProgressEvData,?> |
evBack
It is also aggregated in
#ev |
(package private) FileCluster |
fileCluster |
(package private) FilepathFilterM |
fileFilter |
(package private) long |
lastTimeProgress |
(package private) FileRemoteProgressEvData |
progress |
(package private) long |
startTime |
(package private) TimeOrder |
timeOrderProgress
The time order is used to transmit a progress event after a given time,
to prevent too much traffic for fast walking.
|
private FileRemoteWalker.WalkInfo |
walkInfo
Information to the current level of walking.
|
Constructor and Description |
---|
WalkFileTreeVisitor(FileCluster fileCluster,
boolean refreshChildren,
FileRemoteCmdEventData co,
EventWithDst<FileRemoteProgressEvData,?> evBack,
boolean bDbg)
Constructs the instance.
|
Modifier and Type | Method and Description |
---|---|
java.nio.file.FileVisitResult |
postVisitDirectory(java.nio.file.Path dir,
java.io.IOException exc)
Invoked from
FileTreeWalker on end of walking through a directory. |
java.nio.file.FileVisitResult |
preVisitDirectory(java.nio.file.Path dir,
java.nio.file.attribute.BasicFileAttributes attrs)
Invoked from
FileTreeWalker if the depths does not reached the end of directory deepness,
also called for empty directories. |
private void |
reset() |
private java.nio.file.FileVisitResult |
translateResult(SortedTreeWalkerCallback.Result result) |
java.nio.file.FileVisitResult |
visitFile(java.nio.file.Path file,
java.nio.file.attribute.BasicFileAttributes attrs)
Invoked for any file entry.
|
java.nio.file.FileVisitResult |
visitFileFailed(java.nio.file.Path file,
java.io.IOException exc) |
public boolean debugOut
final FileCluster fileCluster
final boolean bRefresh
final FileRemoteCmdEventData co
final FileRemoteWalkerCallback callback
private FileRemoteWalker.WalkInfo walkInfo
final EventWithDst<FileRemoteProgressEvData,?> evBack
#ev
final FileRemoteProgressEvData progress
final TimeOrder timeOrderProgress
final FilepathFilterM fileFilter
long startTime
long lastTimeProgress
public WalkFileTreeVisitor(FileCluster fileCluster, boolean refreshChildren, FileRemoteCmdEventData co, EventWithDst<FileRemoteProgressEvData,?> evBack, boolean bDbg)
fileCluster
- The cluster where all FileRemote are able to found by its path.refreshChildren
- true then refreshes the FileRemote which are processedco
- data for the commission especially also the callback for each dir and fileevBack
- given event to be used for messages to the caller, free for usebDbg
- private java.nio.file.FileVisitResult translateResult(SortedTreeWalkerCallback.Result result)
private void reset()
public java.nio.file.FileVisitResult preVisitDirectory(java.nio.file.Path dir, java.nio.file.attribute.BasicFileAttributes attrs) throws java.io.IOException
FileTreeWalker
if the depths does not reached the end of directory deepness,
also called for empty directories.
It implements FileVisitor.preVisitDirectory(java.lang.Object, java.nio.file.attribute.BasicFileAttributes)
FileRemote.WalkInfo
as walk info for the current level.
This FileRemote.WalkInfo
are nested or stacked via FileRemote.WalkInfo#parent
, any level has its own
and go back to the first level on postVisitDirectory(Path, IOException)
.
co
-> FileRemoteCmdEventData.callback
-> FileRemoteWalkerCallback#offerParentNode(FileRemote, Object, Object)
is not called for the first level (!) because the first level is the original source directory which should not handled by itself,
only its content should be handled. Also the FileRemoteCmdEventData.selectFilter
is valid only from the second level.
The first level is intrinsic selected because it is the calling source directory.
This is detected by evaluating FileRemote.WalkInfo#parent
which is null for the first level.preVisitDirectory
in interface java.nio.file.FileVisitor<java.nio.file.Path>
java.io.IOException
public java.nio.file.FileVisitResult postVisitDirectory(java.nio.file.Path dir, java.io.IOException exc) throws java.io.IOException
FileTreeWalker
on end of walking through a directory.
It implements FileVisitor.postVisitDirectory(Object, IOException)
FileRemote.WalkInfo
as walk info because it's the end of this level.
co
-> FileRemoteCmdEventData.callback
-> FileRemoteWalkerCallback#finishedParentNode(FileRemote, Object, Object)
is not called for the first level (!) (it's the last call) because the first level is the original source directory which should not handled by itself,
see adequate in preVisitDirectory(...).postVisitDirectory
in interface java.nio.file.FileVisitor<java.nio.file.Path>
java.io.IOException
public java.nio.file.FileVisitResult visitFile(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attrs) throws java.io.IOException
preVisitDirectory(Path, BasicFileAttributes)
if the depth of the tree is reached. Only then the Path is a directory.
This method is not invoked if preVisitDirectory(Path, BasicFileAttributes)
is invoked for the Path.
See FileVisitor.visitFile(java.lang.Object, java.nio.file.attribute.BasicFileAttributes)
visitFile
in interface java.nio.file.FileVisitor<java.nio.file.Path>
java.io.IOException
public java.nio.file.FileVisitResult visitFileFailed(java.nio.file.Path file, java.io.IOException exc) throws java.io.IOException
visitFileFailed
in interface java.nio.file.FileVisitor<java.nio.file.Path>
java.io.IOException