public class GuiffyDiff
extends java.lang.Thread
GuiffyDiff supports Guiffy's two "diff" algorithm choices and supports Guiffy's two verify methods. GuiffyDiff properties include Guiffy's file compare ignore and show options. Plus, the File Encoding format can be specified.
GuiffyDiff has 4 different ways to run: 1) Minimum Lines Diff compare(the default) 2) Minimum Blocks Diff compare 3) Verify files match(Byte-by-Byte) or 4) Verify files match with text compare. Both compare runs and the verify with text compare ignore end-of-line differences and apply the File Encoding(if selected). Both compare runs and the verify with text compare apply all the ignore and show properties selected.
The default Minimum Lines Diff compare will usually find fewer lines different in its results while the Minimum Blocks Diff compare will usually find fewer difference blocks in its results. GuiffyDiff will automatically switch the Minimum Lines Diff compare to a Minimum Blocks Diff if either file has more than 32K lines.
Both Verify files match runs stop as soon as they find a difference. Verify runs do NOT write to the ourput pipe. They only close the output pipe when finished(reader gets -1 returned) and set the FilesMatchResult. The Byte-by-Byte files match verify, as its name suggests, is a binary file compare.
Guiffy 5.4 release added Folder Compares. Folder Compares apply the Folder Compare AND File Compare options.
Note: Both folder names and file names support archive file types. A folder name can be an acrhive file name such as C:/release_11_2.zip. or an archive file name including a subfolder name such as C:/release_11_2.zip/source. A file name can be an archive file name including a file name such as C:/release_11_2.zip/source/Jiffy.java.
Example code :
The following instantiates a GuiffyDiff object
with all its properties set to default. Here we also instantiate the
PipedWriter for GuiffyDiff, instantiate the PipedReader and connect it
to the PipedWriter.
import com.guiffy.inside.*; ... PipedWriter jifOutPipe = new PipedWriter( ); PipedReader jifInpPipe = new PipedReader(jifOutPipe); GuiffyDiff jiffer = new GuiffyDiff( jifOutPipe );Then, we set GuiffyDiff's properties(at least the 2 filenames).
jiffer.set1stFile(firFileName); jiffer.set2ndFile(secFileName);Then, we run GuiffyDiff and read its output(if any) and "print" it.
jiffer.start(); try { char[] buffer = new char[4096]; int chars_read; // Read the diff output from the pipe while ( (chars_read = jifInpPipe.read(buffer)) != -1 ) { String chars_out = new String(buffer, 0, chars_read); System.out.print(chars_out); } } catch (Exception e) { System.err.println( "Jiff error: " + e.toString() ); System.exit(103); }Then, we check the return status.
int rstat = jiffer.getStatus(); if (rstat != GuiffyDiff.OK) { System.err.println( "Jiff error: GuiffyDiff status = " + rstat); System.exit(rstat); }And, if we were running either type of verify(no diff output), we check the match result flag.
if (verifyBxb == true || verifyTxt == true) { boolean fmatch = jiffer.getFilesMatchResult(); if (fmatch == true) { System.out.println("Files Matched"); System.exit(0); } else { System.out.println("Files NOT Matched"); System.exit(100); } }
Thread
,
PipedWriter
,
PipedReader
Modifier and Type | Field | Description |
---|---|---|
static int |
CANT_FIND_1STFILE |
|
static int |
CANT_FIND_1STFOLDER |
|
static int |
CANT_FIND_2NDFILE |
|
static int |
CANT_FIND_2NDFOLDER |
|
static int |
CANT_READ_1STFILE |
|
static int |
CANT_READ_1STFOLDER |
|
static int |
CANT_READ_2NDFILE |
|
static int |
CANT_READ_2NDFOLDER |
|
static int |
ENCODING_NOTAVAIL |
|
static int |
ERRORIS_EXCEPTION |
|
static int |
EVALPER_ISEXPIRED |
|
static int |
GUIFFYDIFF_NOTALLOWED |
|
static int |
ISAFILE_1STFOLDER |
|
static int |
ISAFILE_2NDFOLDER |
|
static int |
ISAFOLDER_1STFILE |
|
static int |
ISAFOLDER_2NDFILE |
|
static int |
OK |
Constructor | Description |
---|---|
GuiffyDiff(java.io.PipedWriter opw) |
Modifier and Type | Method | Description |
---|---|---|
int |
getFilesAdded() |
Returns Files Added count.
|
int |
getFilesChanged() |
Returns Files Changed count.
|
int |
getFilesDeleted() |
Returns Files Deleted count.
|
int |
getFilesMatched() |
Returns Files Matched count.
|
boolean |
getFilesMatchResult() |
Returns Verify Files Match result true or false.
|
long |
getLinesDeleted() |
Returns Lines Deleted count.
|
long |
getLinesInserted() |
Returns Lines Inserted count.
|
long |
getLinesMatched() |
Returns Lines Matched count.
|
int |
getStatus() |
Returns Status of Diff Run.
|
java.lang.String[] |
list(java.lang.String directoryname,
java.io.FilenameFilter filenameFilter) |
Returns the names of the files in the directory which are accepted
by filenameFilter in a newly created array.
|
void |
run() |
|
void |
set1stFile(java.lang.String firstname) |
Sets the 1st File Name.
|
void |
set1stFileEncoding(java.lang.String encods) |
Sets 1st File Encoding.
|
void |
set1stFolder(java.lang.String firstname) |
Sets the 1st Folder Name.
|
void |
set1stReader(java.io.Reader firstrder) |
Sets the 1st Reader.
|
void |
set2ndFile(java.lang.String secndname) |
Sets the 2nd File Name.
|
void |
set2ndFileEncoding(java.lang.String encods) |
Sets 2nd File Encoding.
|
void |
set2ndFolder(java.lang.String secndname) |
Sets the 2nd Folder Name.
|
void |
set2ndReader(java.io.Reader secndrder) |
Sets the 2nd Reader.
|
void |
setASL(boolean aslo) |
|
void |
setExpandedBlock(int expblk) |
Sets Block Expander for Minimize Blocks Diff.
|
void |
setFileEncoding(java.lang.String encods) |
Sets File Encoding for 1st and 2nd files.
|
void |
setIgnoreAllFilsExcept(boolean igafe) |
Sets ignore All files Except, (folder compares)
true or false.
|
void |
setIgnoreAllTypsExcept(boolean igate) |
Sets ignore All filetypes Except, (folder compares)
true or false.
|
void |
setIgnoreBlank(boolean ignblk) |
Sets IgnoreBlanklines option true or false.
|
void |
setIgnoreCase(boolean igncas) |
Sets IgnoreCase option true or false.
|
void |
setIgnoreDateandTime(boolean igmdat) |
Sets ignore modified date and time (folder compares) option
true or false.
|
void |
setIgnoreEmbeddedWhiteSpace(boolean igs) |
Sets Ignore Embedded type Whitespace flag.
|
void |
setIgnoreEOLWhiteSpace(boolean igs) |
Sets Ignore EOL type Whitespace flag.
|
void |
setIgnoreField(int begcol,
int endcol) |
Sets IgnoreField option columns xxx thru yyy.
|
void |
setIgnoreField2(int begcol,
int endcol) |
Sets IgnoreField2 option columns xxx thru yyy.
|
void |
setIgnoreFileSize(boolean igfsiz) |
Sets ignore file size (folder compares) option
true or false.
|
void |
setIgnoreFils(java.lang.String igfils) |
Sets ignore files, (folder compares) list.
|
void |
setIgnoreLeadingWhiteSpace(boolean igs) |
Sets Ignore Leading type Whitespace flag.
|
void |
setIgnoreSubs(java.lang.String igsubs) |
Sets ignore subfolders, (folder compares) list.
|
void |
setIgnoreSymbolicLinks(boolean igsyml) |
Sets ignore Symbolic Links (folder compares) option
true or false.
|
void |
setIgnoreTrailingWhiteSpace(boolean igs) |
Sets Ignore Trailing type Whitespace flag.
|
void |
setIgnoreTyps(java.lang.String igtyps) |
Sets ignore filetypes, (folder compares) list.
|
void |
setIgnoreWhitespace(boolean ignwhi) |
Sets IgnoreWhitespace of all types option true or false.
|
void |
setMinimumBlocksDiff(boolean minblk) |
Sets Minimize Blocks Changed Diff option
true or false.
|
void |
setMinimumLinesDiff(boolean minlin) |
Sets Minimize Lines Changed Diff option
true or false.
|
void |
setOEMLicenseKey(java.io.ByteArrayInputStream bais) |
|
void |
setQtRexs(java.lang.String[] rxs,
int rxi) |
Sets Quietly Ignore Regular Expressions list.
|
void |
setQtRexTyps(java.lang.String[] rxs,
java.lang.String[] rxt,
int rxi) |
Sets Quietly Ignore Regular Expressions list and Types.
|
void |
setShowAdds(boolean sho) |
Sets show files Added (folder compares) option.
|
void |
setShowArchs(boolean sharcs) |
Sets show Archive filetypes, recursively (folder compares) option
true or false.
|
void |
setShowChgs(boolean sho) |
Sets show files Changed (folder compares) option.
|
void |
setShowContextDiffs(boolean shocxt) |
Sets Show Context Differences option true or false.
|
void |
setShowContextSize(int conlns) |
Sets Show Context Differences Size option.
|
void |
setShowDels(boolean sho) |
Sets show files Deleted (folder compares) option.
|
void |
setShowIgnoredDiffs(boolean sig) |
Sets Show Ignored Diffs default is false.
|
void |
setShowLineNumbers(boolean sholno) |
Sets Show Line Numbers option true or false.
|
void |
setShowMats(boolean sho) |
Sets show Matching files (folder compares) option.
|
void |
setShowOnlyDiffs(boolean shonly) |
Sets Show Only Differences option true or false.
|
void |
setShowSubs(boolean shsubs) |
Sets show subfolders, recursively (folder compares) option
true or false.
|
void |
setTabSize(int tabsiz) |
Sets Tab Size option.
|
void |
setUnified(boolean unifid) |
Sets Show Differences in Unified Diff format option true or false.
|
void |
setUserLicenseKey(java.io.ByteArrayInputStream bais) |
|
void |
setVerifyBxb(boolean verbxb) |
Sets Verify files match, byte-by-byte option
true or false.
|
void |
setVerifySub(boolean verfol) |
Sets Verify subfolders match, folder compare option
true or false.
|
void |
setVerifySubFolderRun(boolean vsfr) |
Sets Verify SubFolder Run, (folder compares)
true or false.
|
void |
setVerifyTxt(boolean vertxt) |
Sets Verify files match, text compare option
true or false.
|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public static final int OK
public static final int CANT_FIND_1STFILE
public static final int CANT_FIND_2NDFILE
public static final int CANT_READ_1STFILE
public static final int CANT_READ_2NDFILE
public static final int ISAFOLDER_1STFILE
public static final int ISAFOLDER_2NDFILE
public static final int ENCODING_NOTAVAIL
public static final int ERRORIS_EXCEPTION
public static final int EVALPER_ISEXPIRED
public static final int CANT_FIND_1STFOLDER
public static final int CANT_FIND_2NDFOLDER
public static final int CANT_READ_1STFOLDER
public static final int CANT_READ_2NDFOLDER
public static final int ISAFILE_1STFOLDER
public static final int ISAFILE_2NDFOLDER
public static final int GUIFFYDIFF_NOTALLOWED
public void run()
run
in class java.lang.Thread
public boolean getFilesMatchResult()
public long getLinesDeleted()
public long getLinesInserted()
public long getLinesMatched()
public int getFilesDeleted()
public int getFilesAdded()
public int getFilesChanged()
public int getFilesMatched()
public int getStatus()
OK = 0; CANT_FIND_1STFILE = 1; // Can't find 1st file CANT_FIND_2NDFILE = 2; // Can't find 2nd file CANT_READ_1STFILE = 3; // Can't read 1st file CANT_READ_2NDFILE = 4; // Can't read 2nd file ISAFOLDER_1STFILE = 5; // 1st file is a folder ISAFOLDER_2NDFILE = 6; // 2nd file is a folder ENCODING_NOTAVAIL = 7; // File Encoding specified NA ERRORIS_EXCEPTION = 8; // Exception // (perhaps, encoding format) EVALPER_ISEXPIRED = 9; // Evaluation period has expired CANT_FIND_1STFOLDER = 11; // Can't file 1st folder CANT_FIND_2NDFOLDER = 12; // Can't file 2nd folder CANT_READ_1STFOLDER = 13; // Can't read 1st folder CANT_READ_2NDFOLDER = 14; // Can't read 2nd folder ISAFILE_1STFOLDER = 15; // 1st folder is a file ISAFILE_2NDFOLDER = 16; // 2nd folder is a file GUIFFYDIFF_NOTALLOWED = 17; // Not allowed, requires eXpert license
public java.lang.String[] list(java.lang.String directoryname, java.io.FilenameFilter filenameFilter)
directoryname
- the directory name as a complete path.filenameFilter
- the FilenameFilter.public void setASL(boolean aslo)
public void set1stFile(java.lang.String firstname)
firstname
- the 1st File name as a complete path.public void set2ndFile(java.lang.String secndname)
secndname
- the 2nd File name as a complete path.public void set1stReader(java.io.Reader firstrder)
firstrder
- the 1st Reader.public void set2ndReader(java.io.Reader secndrder)
secndrder
- the 2nd Reader.public void setExpandedBlock(int expblk)
expblk
- the integer value that expands the block resynch
required for Minimize Blocks Diff.public void setFileEncoding(java.lang.String encods)
encods
- the String value of the Encoding such as "ASCII", "UTF8",
"SJIS", "Cp500" (for EBCDIC) etc. - Over 100 formats supported.public void set1stFileEncoding(java.lang.String encods)
encods
- the String value of the Encoding such as "ASCII", "UTF8",
"SJIS", "Cp500" (for EBCDIC) etc. - Over 100 formats supported.public void set2ndFileEncoding(java.lang.String encods)
encods
- the String value of the Encoding such as "ASCII", "UTF8",
"SJIS", "Cp500" (for EBCDIC) etc. - Over 100 formats supported.public void setIgnoreCase(boolean igncas)
igncas
- the boolean value that determines whether case differences
are ignored during the compare.public void setIgnoreField(int begcol, int endcol)
begcol
- the ignore field's beginning columnendcol
- the ignore field's ending columnpublic void setIgnoreField2(int begcol, int endcol)
begcol
- the ignore field's beginning columnendcol
- the ignore field's ending columnpublic void setIgnoreWhitespace(boolean ignwhi)
ignwhi
- the boolean value that determines whether whitespace
differences are ignored during the compare.public void setIgnoreLeadingWhiteSpace(boolean igs)
igs
- the boolean value that determines whether leading whitespace
differences are ignored during the compare.public void setIgnoreEmbeddedWhiteSpace(boolean igs)
igs
- the boolean value that determines whether embedded whitespace
differences are ignored during the compare.public void setIgnoreTrailingWhiteSpace(boolean igs)
igs
- the boolean value that determines whether trailing whitespace
differences are ignored during the compare.public void setIgnoreEOLWhiteSpace(boolean igs)
igs
- the boolean value that determines whether EOL whitespace
differences are ignored during the compare.public void setIgnoreBlank(boolean ignblk)
ignblk
- the boolean value that determines whether blankline
differences are ignored during the compare.public void setMinimumBlocksDiff(boolean minblk)
minblk
- the boolean value that determines which diff
algorithm is used - Minimize Lines/Blocks changed.public void setMinimumLinesDiff(boolean minlin)
minlin
- the boolean value that determines which diff
algorithm is used - Minimize Lines/Blocks changed.public void setShowIgnoredDiffs(boolean sig)
sig
- the boolean value for show ignored diffspublic void setQtRexs(java.lang.String[] rxs, int rxi)
rxs
- the String array of ignore regular expressions.rxi
- the number of regular expressions.public void setQtRexTyps(java.lang.String[] rxs, java.lang.String[] rxt, int rxi)
rxs
- the String array of ignore regular expressions.rxt
- the String array of Types(Line,Part, or Block).rxi
- the number of regular expressions.public void setShowContextDiffs(boolean shocxt)
shocxt
- the boolean value that specifies to show context around
differences.public void setShowContextSize(int conlns)
conlns
- the number of lines of context to show before and after
differences. If less than 1, default of 10 is used.
If greater than 48, value of 48 is used.public void setUnified(boolean unifid)
unifid
- the boolean value that specifies to show unified diff format
differences.
Use the setShowContextSize(int conlns) method to set the number of lines of context.public void setShowLineNumbers(boolean sholno)
sholno
- the boolean value that specifies to show Line Numbers.public void setShowOnlyDiffs(boolean shonly)
shonly
- the boolean value that specifies to show only the
differences.public void setTabSize(int tabsiz)
tabsiz
- the int value that specifies tab sizes.public void setVerifyBxb(boolean verbxb)
verbxb
- the boolean value that determines whether files match
are verified, byte-by-byte.public void setVerifyTxt(boolean vertxt)
vertxt
- the boolean value that determines whether files match
are verified, text compare.public void setVerifySub(boolean verfol)
verfol
- the boolean value that determines whether subfolders match
are verified.public void set1stFolder(java.lang.String firstname)
firstname
- the 1st Folder name as a complete path.public void set2ndFolder(java.lang.String secndname)
secndname
- the 2nd Folder name as a complete path.public void setIgnoreDateandTime(boolean igmdat)
igmdat
- the boolean value that determines whether modified
date and time is ignored during folder compares.public void setIgnoreFileSize(boolean igfsiz)
igfsiz
- the boolean value that determines whether file
size is ignored during folder compares.public void setIgnoreSymbolicLinks(boolean igsyml)
igsyml
- the boolean value that determines whether symbolic
links are ignored during folder compares.public void setShowSubs(boolean shsubs)
shsubs
- the boolean value that determines whether to show
subfolders (recursively) during folder compares.public void setShowArchs(boolean sharcs)
sharcs
- the boolean value that determines whether to show
subfolders (recursively) during folder compares.public void setShowMats(boolean sho)
sho
- the boolean value for whether to show Matching files.public void setShowAdds(boolean sho)
sho
- the boolean value for whether to show files Added.public void setShowDels(boolean sho)
sho
- the boolean value for whether to show files Deleted.public void setShowChgs(boolean sho)
sho
- the boolean value for whether to show files Changed.public void setIgnoreSubs(java.lang.String igsubs)
igsubs
- the string value list of subfolders to ignore.
The list of subfolders are separated by ';'s.
Wildcard * prefix/suffix patterns supported.public void setIgnoreFils(java.lang.String igfils)
igfils
- the string value list of files to ignore.
The list of files are separated by ';'s.
Wildcard * prefix/suffix patterns supported.public void setIgnoreAllFilsExcept(boolean igafe)
igafe
- the boolean value that indicates All Except
files are ignored during folder compares.public void setIgnoreTyps(java.lang.String igtyps)
igtyps
- the string value list of filetypes to ignore.
The list of filetypes like .class are separated by ';'s.public void setIgnoreAllTypsExcept(boolean igate)
igate
- the boolean value that indicates All Except
filetypes are ignored during folder compares.public void setVerifySubFolderRun(boolean vsfr)
vsfr
- the boolean value that indicates Verfiy SubFolder
Run - stop on first diff..public void setOEMLicenseKey(java.io.ByteArrayInputStream bais)
public void setUserLicenseKey(java.io.ByteArrayInputStream bais)