public class FileCallbackLocalCmp extends java.lang.Object implements FileRemoteWalkerCallback
FileRemote
instances. The result of comparison is set in any file in FileRemote.setMarked(int)
whereby the argument is an int as mask with one of the bits in
FileMark.cmpAlone
if the second file is not existing.
FileMark.cmpContentEqual
if both files are compared by content and have equal content, whereby comments etc. are maybe ignored.
FileMark.cmpContentNotEqual
if both files are compared with different content.
FileMark.cmpLenTimeEqual
if both files have the same length and time stamp. They can be differ though!
But the difference is not detected if mode
have the bit FileCompare.onlyTimestamp
is set.
FileMark.cmpFileDifferences
if the length is differ.
FileMark.cmpTimeGreater
or FileMark.cmpTimeLesser
if there are time differences.
Note that it is possible that the files have also set FileMark.cmpContentEqual
if only the timestamp is touched.
FileMark.selectSomeInDir
if any differences are in the dir and sub directories
FileMark.cmpMissingFiles
if some files are missing in the dir and sub directories
org.vishia.gral.widget.GralFileSelector#setCmpFileResult(int)
see there.Modifier and Type | Class and Description |
---|---|
(package private) class |
FileCallbackLocalCmp.CompareCtrl |
SortedTreeWalkerCallback.Result
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
aborted |
private java.lang.String |
basepath1 |
private FileRemoteWalkerCallback |
callbackUser
Event to walk through the second tree.
|
private FileCallbackLocalCmp.CompareCtrl |
cmpCtrl |
private FileRemote |
dir1 |
private FileRemote |
dir2 |
private EventWithDst<FileRemoteProgressEvData,?> |
evBack
Event instance for user callback.
|
(package private) long |
minDiffTimestamp
Files with a lesser difference in time (2 sec) are seen as equal in time stamp.
|
(package private) int |
mode
one of the bits
FileCompare.onlyTimestamp =
FileCompare.withoutLineend =
FileCompare.withoutEndlineComment =
FileCompare.withoutComment =
used for the comparison itself. |
private FileRemoteProgressEvData |
progress |
static java.lang.String |
sVersion
Version, history and license.
|
(package private) FileRemoteWalkerCallback |
XXXcallbackMarkSecondAlone
Callback to mark all files of the second directory as 'alone' on open directory.
|
private int |
zBasePath1 |
callbackTemplate
Constructor and Description |
---|
FileCallbackLocalCmp(FileRemote dir1,
FileRemote dir2,
int cmpMode,
FileRemoteWalkerCallback callbackUser,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Constructs an instance to execute a comparison of directory trees.
|
Modifier and Type | Method and Description |
---|---|
(package private) int |
compareFile(FileRemote file1,
FileRemote file2)
Compare two files.
|
(package private) boolean |
compareFileContent(FileRemote file1,
FileRemote file2)
Compare two files.
|
void |
finished(FileRemote startDir)
Invoked after finishing the walking through.
|
SortedTreeWalkerCallback.Result |
finishedParentNode(FileRemote file,
java.lang.Object data,
java.lang.Object oWalkInfo)
Checks whether all files are compared or whether there are alone files.
|
SortedTreeWalkerCallback.Result |
offerLeafNode(FileRemote file,
java.lang.Object info)
Invoked for any node which has no children or which is not processed because the depth of walking through the tree is reached.
|
SortedTreeWalkerCallback.Result |
offerParentNode(FileRemote dir,
java.lang.Object oPath,
java.lang.Object oWalkInfo)
Invoked on start on walking through a parent node which have children.
|
private java.lang.String |
readIgnoreComment(java.io.BufferedReader reader) |
boolean |
shouldAborted()
Returns true if the tree walking should be terminated respectively aborted.
|
void |
start(FileRemote startDir,
FileRemoteCmdEventData co)
On start of comparison it refreshes the second dir tree.
|
public static final java.lang.String sVersion
offerParentNode(FileRemote, Object, Object)
do not skip but enter empty directories,
because the files intern should be also marked with FileMark.cmpAlone
.
FileCompare.onlyTimestamp
etc. They are the same values. Unique!
FileCallbackLocalCmp(FileRemote, FileRemote, int, FileRemoteWalkerCallback, EventWithDst)
has a new argument cmpMode
FileRemoteProgressEvData
: remove progress.show(...)
because it is called in the timer thread instead. Independent of continue the process here.
readIgnoreComment(BufferedReader)
: The second line after //line is ignored too. In a rarely case
it was the only one line which was different, and the comparison has failed.
compareFileContent(FileRemote, FileRemote)
: if the 2. file is longer, it is a difference!
FileCallbackLocalCmp.CompareCtrl
: Comparison with suppressed parts especially comments.
private final FileCallbackLocalCmp.CompareCtrl cmpCtrl
private final FileRemote dir1
private final FileRemote dir2
private final java.lang.String basepath1
private final int zBasePath1
private final EventWithDst<FileRemoteProgressEvData,?> evBack
private final FileRemoteProgressEvData progress
private final FileRemoteWalkerCallback callbackUser
int mode
FileCompare.onlyTimestamp
=
FileCompare.withoutLineend
=
FileCompare.withoutEndlineComment
=
FileCompare.withoutComment
=
used for the comparison itself.long minDiffTimestamp
boolean aborted
final FileRemoteWalkerCallback XXXcallbackMarkSecondAlone
#offerParentNode(FileRemote)
on any directory
in the dir1. A new dir is searched in the dir2 tree, then the children in 1 level are marked.public FileCallbackLocalCmp(FileRemote dir1, FileRemote dir2, int cmpMode, FileRemoteWalkerCallback callbackUser, EventWithDst<FileRemoteProgressEvData,?> evBack)
FileCompare.onlyTimestamp
then full content comparison is not done.
The comparison is very more faster (seen 10 times).dir1
- One directory which contains a file tree. All files are compared with dir2dir2
- The other directory to comparecmpMode
- can contain the bits FileCompare.onlyTimestamp
, FileCompare.withoutLineend
, FileCompare.withoutEndlineComment
, FileCompare.withoutComment
,callbackUser
- Maybe null. If given, on each directory entry, exit and file the callback will be invoked
with the handled directory or file. The second argument is an boxed Integer, which contains the bits from
FileMark
to inform what is with that file.evBack
- maybe null. If given this back event is used to show the progression of the comparison.
The timeOrder is set with datapublic void start(FileRemote startDir, FileRemoteCmdEventData co)
start
in interface SortedTreeWalkerCallback<FileRemote,FileRemoteCmdEventData>
public SortedTreeWalkerCallback.Result offerParentNode(FileRemote dir, java.lang.Object oPath, java.lang.Object oWalkInfo)
SortedTreeWalkerCallback
#offerLeafNode(TypeNode)
is not invoked.offerParentNode
in interface SortedTreeWalkerCallback<FileRemote,FileRemoteCmdEventData>
oPath
- Specific data presentation of the nodeoWalkInfo
- internal possible information about walking, depending on usage.public SortedTreeWalkerCallback.Result finishedParentNode(FileRemote file, java.lang.Object data, java.lang.Object oWalkInfo)
finishedParentNode
in interface SortedTreeWalkerCallback<FileRemote,FileRemoteCmdEventData>
file
- the node which was walked throughdata
- Specific data presentation of the nodeoWalkInfo
- internal possible information about walking, depending on usage.public SortedTreeWalkerCallback.Result offerLeafNode(FileRemote file, java.lang.Object info)
SortedTreeWalkerCallback
#offerLeafNode(Object)
, only one of both is called for a node.
For example it is invoked for a sub directory only if the depth is reached and #offerParentNode(TypeNode)
is not called.offerLeafNode
in interface SortedTreeWalkerCallback<FileRemote,FileRemoteCmdEventData>
public boolean shouldAborted()
SortedTreeWalkerCallback
shouldAborted
in interface SortedTreeWalkerCallback<FileRemote,FileRemoteCmdEventData>
int compareFile(FileRemote file1, FileRemote file2)
file1
- file2
- both file should be exist. It is tested before.FileMark.cmpContentEqual
or boolean compareFileContent(FileRemote file1, FileRemote file2) throws java.io.IOException
file
- java.io.FileNotFoundException
java.io.IOException
private java.lang.String readIgnoreComment(java.io.BufferedReader reader) throws java.io.IOException
java.io.IOException
public void finished(FileRemote startDir)
SortedTreeWalkerCallback
finished
in interface SortedTreeWalkerCallback<FileRemote,FileRemoteCmdEventData>