com.guiffy.inside
Class GuiffySureMerge

java.lang.Object
  extended by java.lang.Thread
      extended by com.guiffy.inside.GuiffySureMerge
All Implemented Interfaces:
java.lang.Runnable

public class GuiffySureMerge
extends java.lang.Thread

Class GuiffySureMerge is the Merge engine for including SureMerge inside Java applications. GuiffySureMerge extends Thread.

Guiffy's 3-way smart merge, SureMerge, automatically merges all changes except those which conflict. SureMerge's conflict detection algorithm treats inserts and deletes(not just changes) as conflicts. SureMerge extends its conflict attention span to include modifications very near to each other but not necessarily overlapping. Plus, the Attention Focus Expander option allows the user to expand the conflict/overlap area.

Guiffy compares/merges source(text) files of any type - supports Unicode character set. And, Guiffy accepts all 3 forms of end-of-line.

Example code :
The following instantiates a GuiffySureMerge object with all its properties set to default.

import com.guiffy.inside.*;
      ...
      GuiffySureMerge sMerge = new GuiffySureMerge( );
Then, we set GuiffySureMerge's filenames. NOTES: If the ResultFileName is null, the results are NOT saved(written) - its a "check merge" run. If the ParentFileName is null, All the changes are saved as Attentions. And, we setup an exitHook.
      sMerge.set1stFile(firFileName);
      sMerge.set2ndFile(secFileName);
      sMerge.setParentFile(parFileName);
      sMerge.setResultFile(resFileName);
      GuiffyHook hook3way = new GuiffyHook();
      hook3way.setGuiffySureMerge(sMerge);
      sMerge.setGuiffyExit(hook3way);
Then, we run GuiffySureMerge.
      sMerge.start();
Then, (in the exitHook) we check the return status.
      if(gsm != null) {
        int rstat = gsm.getStatus();

        if (rstat != GuiffySureMerge.OK) {
            System.err.println( "SureMerge error: status=" + rstat);
            System.exit(rstat);
        }
And, if the Merge ran, we get the SureMerge metrics.
        System.err.println("NumberofChanges=" + gsm.getNumberofChanges() );
        System.err.println("Numberof1stApps=" + gsm.getNumberof1stApplied() );
        System.err.println("Numberof2ndApps=" + gsm.getNumberof2ndApplied() );
        System.err.println("NumberofAttents=" + gsm.getNumberofAttentions() );
      } 

Version:
5.1 -- developed in April, 2003
Author:
Guiffy Software, Inc. by Bill Ritcher
See Also:
Thread

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static int CANT_FIND_1STFILE
           
static int CANT_FIND_2NDFILE
           
static int CANT_FIND_PARFILE
           
static int CANT_READ_1STFILE
           
static int CANT_READ_2NDFILE
           
static int CANT_READ_PARFILE
           
static int CANT_WRIT_RESFILE
           
static int ENCODING_NOTAVAIL
           
static int ERRORIS_EXCEPTION
           
static int EVALPER_ISEXPIRED
           
static int ISAFOLDER_1STFILE
           
static int ISAFOLDER_2NDFILE
           
static int ISAFOLDER_PARFILE
           
static int OK
           
static int SUREMERGE_ISCONFUSED
           
static int SUREMERGE_NOTALLOWED
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
GuiffySureMerge()
           
 
Method Summary
 java.lang.String get1stFileEncoding()
           
 java.lang.String get2ndFileEncoding()
           
 int getNumberof1stApplied()
          Returns the number of changes applied from 1st.
 int getNumberof2ndApplied()
          Returns the number of changes applied from 2nd.
 int getNumberofAttentions()
          Returns the number of unresolved Attentions.
 int getNumberofChanges()
          Returns the number of change blocks.
 java.lang.String getparFileEncoding()
           
 java.lang.String getsavFileEncoding()
           
 int getStatus()
          Returns Status of SureMerge Run.
 void run()
           
 void set1stFile(java.lang.String firstname)
          Sets the 1st File Name.
 void set1stFileEncoding(java.lang.String encods)
          Sets File Encoding for 1st files.
 void set2ndFile(java.lang.String secndname)
          Sets the 2nd File Name.
 void set2ndFileEncoding(java.lang.String encods)
          Sets File Encoding for 2nd files.
 void setEncodingAutoMode(boolean sam)
          Sets the Encoding AutoMode.
 void setEOLAutoMode(boolean sam)
          Sets the EOL AutoMode.
 void setEOLOption(java.lang.String eolopt)
          Sets Write EOLs option for Saved files.
 void setExpandedBlock(int expblk)
          Sets Block Expander for Minimize Blocks Diff.
 void setFileEncoding(java.lang.String encods)
          Sets File Encoding for 1st, 2nd and Parent files.
 void setGuiffyExit(GuiffyExit hook)
          Sets the GuiffyExit hook of the GuiffySureMerge If set to null, a previously added GuiffyExit hook will be removed.
 void setIgnoreBlank(boolean ignblk)
          Sets IgnoreBlanklines option true or false.
 void setIgnoreCase(boolean igncas)
          Sets IgnoreCase option true or false.
 void setIgnoreEmbeddedWhiteSpace(boolean igs)
          Sets Ignore Embedded 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 setIgnoreLeadingWhiteSpace(boolean igs)
          Sets Ignore Leading type Whitespace flag.
 void setIgnoreTrailingWhiteSpace(boolean igs)
          Sets Ignore Trailing type Whitespace flag.
 void setIgnoreWhitespace(boolean ignwhi)
          Sets IgnoreWhitespace of all types option true or false.
 void setOEMLicenseKey(java.io.ByteArrayInputStream bais)
          Set License Key based on special OEMKey ByteArrayInputStream
 void setParentFile(java.lang.String parntname)
          Sets the Parent File Name.
 void setParFileEncoding(java.lang.String encods)
          Sets File Encoding for Parent files.
 void setPromote(boolean promo)
          Sets Promote option true or false.
 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 setResultFile(java.lang.String resltname)
          Sets the Result File Name.
 void setSaveEncoding(java.lang.String encods)
          Sets Save Encoding for MergeResult file.
 void setTabSize(int tabsiz)
          Sets Tab Size option.
 
Methods inherited from class java.lang.Thread
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, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OK

public static final int OK
See Also:
Constant Field Values

CANT_FIND_1STFILE

public static final int CANT_FIND_1STFILE
See Also:
Constant Field Values

CANT_FIND_2NDFILE

public static final int CANT_FIND_2NDFILE
See Also:
Constant Field Values

CANT_FIND_PARFILE

public static final int CANT_FIND_PARFILE
See Also:
Constant Field Values

CANT_READ_1STFILE

public static final int CANT_READ_1STFILE
See Also:
Constant Field Values

CANT_READ_2NDFILE

public static final int CANT_READ_2NDFILE
See Also:
Constant Field Values

CANT_READ_PARFILE

public static final int CANT_READ_PARFILE
See Also:
Constant Field Values

CANT_WRIT_RESFILE

public static final int CANT_WRIT_RESFILE
See Also:
Constant Field Values

ISAFOLDER_1STFILE

public static final int ISAFOLDER_1STFILE
See Also:
Constant Field Values

ISAFOLDER_2NDFILE

public static final int ISAFOLDER_2NDFILE
See Also:
Constant Field Values

ISAFOLDER_PARFILE

public static final int ISAFOLDER_PARFILE
See Also:
Constant Field Values

ENCODING_NOTAVAIL

public static final int ENCODING_NOTAVAIL
See Also:
Constant Field Values

ERRORIS_EXCEPTION

public static final int ERRORIS_EXCEPTION
See Also:
Constant Field Values

EVALPER_ISEXPIRED

public static final int EVALPER_ISEXPIRED
See Also:
Constant Field Values

SUREMERGE_ISCONFUSED

public static final int SUREMERGE_ISCONFUSED
See Also:
Constant Field Values

SUREMERGE_NOTALLOWED

public static final int SUREMERGE_NOTALLOWED
See Also:
Constant Field Values
Constructor Detail

GuiffySureMerge

public GuiffySureMerge()
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getStatus

public int getStatus()
Returns Status of SureMerge Run.

Returns:
the int value that indicates the status of run:
   OK = 0;
   CANT_FIND_1STFILE = 1;  // Can't find 1st file
   CANT_FIND_2NDFILE = 2;  // Can't find 2nd file
   CANT_FIND_PARFILE = 3;  // Can't find Parent file
   CANT_READ_1STFILE = 4;  // Can't read 1st file
   CANT_READ_2NDFILE = 5;  // Can't read 2nd file
   CANT_READ_PARFILE = 6;  // Can't read Parent file
   CANT_WRIT_RESFILE = 7;  // Can't write/create Result file
   ISAFOLDER_1STFILE = 8;  // 1st file is a folder
   ISAFOLDER_2NDFILE = 9;  // 2nd file is a folder
   ISAFOLDER_PARFILE = 10; // 2nd file is a folder
   ENCODING_NOTAVAIL = 11; // File Encoding specified NA
   ERRORIS_EXCEPTION = 12; // Exception
                           // (perhaps, encoding format)
   EVALPER_ISEXPIRED = 13; // Evaluation period has expired
   SUREMERGE_ISCONFUSED = 14; // SureMerge is Confused
   SUREMERGE_NOTALLOWED = 15; // Not allowed, requires eXpert license

getNumberofChanges

public int getNumberofChanges()
Returns the number of change blocks.

Returns:
the integer value - the number of change blocks of the previous compare or merge operation.

getNumberof1stApplied

public int getNumberof1stApplied()
Returns the number of changes applied from 1st.

Returns:
the integer value - the number of changes applied from 1st during the previous merge operation.

getNumberof2ndApplied

public int getNumberof2ndApplied()
Returns the number of changes applied from 2nd.

Returns:
the integer value - the number of changes applied from 2nd during the previous merge operation.

getNumberofAttentions

public int getNumberofAttentions()
Returns the number of unresolved Attentions.

Returns:
the integer value - the number of unresolved Attentions during the previous merge operation.

get1stFileEncoding

public java.lang.String get1stFileEncoding()

get2ndFileEncoding

public java.lang.String get2ndFileEncoding()

getparFileEncoding

public java.lang.String getparFileEncoding()

getsavFileEncoding

public java.lang.String getsavFileEncoding()

setGuiffyExit

public void setGuiffyExit(GuiffyExit hook)
Sets the GuiffyExit hook of the GuiffySureMerge If set to null, a previously added GuiffyExit hook will be removed.

See Also:
GuiffyExit

setOEMLicenseKey

public void setOEMLicenseKey(java.io.ByteArrayInputStream bais)
Set License Key based on special OEMKey ByteArrayInputStream


set1stFile

public void set1stFile(java.lang.String firstname)
Sets the 1st File Name.

Parameters:
firstname - the 1st File name as a complete path.

set2ndFile

public void set2ndFile(java.lang.String secndname)
Sets the 2nd File Name.

Parameters:
secndname - the 2nd File name as a complete path.

setParentFile

public void setParentFile(java.lang.String parntname)
Sets the Parent File Name.

Parameters:
parntname - the Parent File name as a complete path.

setResultFile

public void setResultFile(java.lang.String resltname)
Sets the Result File Name.

Parameters:
resltname - the Result File name as a complete path.

setExpandedBlock

public void setExpandedBlock(int expblk)
Sets Block Expander for Minimize Blocks Diff. Default is 0.

Parameters:
expblk - the integer value that expands the block resynch required for Minimize Blocks Diff.

setFileEncoding

public void setFileEncoding(java.lang.String encods)
Sets File Encoding for 1st, 2nd and Parent files. Default is the format of the Locale operating environment.

Parameters:
encods - the String value of the Encoding such as "ASCII", "UTF8", "SJIS", "Cp500" (for EBCDIC) etc. - Over 100 formats supported.

set1stFileEncoding

public void set1stFileEncoding(java.lang.String encods)
Sets File Encoding for 1st files. Default is the format of the Locale operating environment.

Parameters:
encods - the String value of the Encoding such as "ASCII", "UTF8", "SJIS", "Cp500" (for EBCDIC) etc. - Over 100 formats supported.

set2ndFileEncoding

public void set2ndFileEncoding(java.lang.String encods)
Sets File Encoding for 2nd files. Default is the format of the Locale operating environment.

Parameters:
encods - the String value of the Encoding such as "ASCII", "UTF8", "SJIS", "Cp500" (for EBCDIC) etc. - Over 100 formats supported.

setParFileEncoding

public void setParFileEncoding(java.lang.String encods)
Sets File Encoding for Parent files. Default is the format of the Locale operating environment.

Parameters:
encods - the String value of the Encoding such as "ASCII", "UTF8", "SJIS", "Cp500" (for EBCDIC) etc. - Over 100 formats supported.

setSaveEncoding

public void setSaveEncoding(java.lang.String encods)
Sets Save Encoding for MergeResult file. Default is the format of the Locale operating environment.

Parameters:
encods - the String value of the Encoding such as "ASCII", "UTF8", "SJIS", "Cp500" (for EBCDIC) etc. - Over 100 formats supported.

setEncodingAutoMode

public void setEncodingAutoMode(boolean sam)
Sets the Encoding AutoMode.

Parameters:
sam - the boolean value for encoding auto-mode.

setIgnoreCase

public void setIgnoreCase(boolean igncas)
Sets IgnoreCase option true or false. Default is false.

Parameters:
igncas - the boolean value that determines whether case differences are ignored during the compare.

setIgnoreField

public void setIgnoreField(int begcol,
                           int endcol)
Sets IgnoreField option columns xxx thru yyy. Default is none(0 thru 0).

Parameters:
begcol - the ignore field's beginning column
endcol - the ignore field's ending column Tabs are expanded according to the TabSize value prior to ignoring a field

setIgnoreField2

public void setIgnoreField2(int begcol,
                            int endcol)
Sets IgnoreField2 option columns xxx thru yyy. Default is none(0 thru 0).

Parameters:
begcol - the ignore field's beginning column
endcol - the ignore field's ending column Tabs are expanded according to the TabSize value prior to ignoring a field

setIgnoreWhitespace

public void setIgnoreWhitespace(boolean ignwhi)
Sets IgnoreWhitespace of all types option true or false. Default is false.

Parameters:
ignwhi - the boolean value that determines whether whitespace differences are ignored during the compare.

setIgnoreLeadingWhiteSpace

public void setIgnoreLeadingWhiteSpace(boolean igs)
Sets Ignore Leading type Whitespace flag. Default is false.

Parameters:
igs - the boolean value that determines whether leading whitespace differences are ignored during the compare.

setIgnoreEmbeddedWhiteSpace

public void setIgnoreEmbeddedWhiteSpace(boolean igs)
Sets Ignore Embedded type Whitespace flag. Default is false.

Parameters:
igs - the boolean value that determines whether embedded whitespace differences are ignored during the compare.

setIgnoreTrailingWhiteSpace

public void setIgnoreTrailingWhiteSpace(boolean igs)
Sets Ignore Trailing type Whitespace flag. Default is false.

Parameters:
igs - the boolean value that determines whether trailing whitespace differences are ignored during the compare.

setIgnoreBlank

public void setIgnoreBlank(boolean ignblk)
Sets IgnoreBlanklines option true or false. Default is false.

Parameters:
ignblk - the boolean value that determines whether blankline differences are ignored during the compare.

setPromote

public void setPromote(boolean promo)
Sets Promote option true or false. Default is false.

Parameters:
promo - the boolean value that determines whether the merge is done as a Promotion.

setQtRexs

public void setQtRexs(java.lang.String[] rxs,
                      int rxi)
Sets Quietly Ignore Regular Expressions list. (Type = Line)

Parameters:
rxs - the String array of ignore regular expressions.
rxi - the number of regular expressions.

setQtRexTyps

public void setQtRexTyps(java.lang.String[] rxs,
                         java.lang.String[] rxt,
                         int rxi)
Sets Quietly Ignore Regular Expressions list and Types.

Parameters:
rxs - the String array of ignore regular expressions.
rxt - the String array of Types(Line,Part, or Block).
rxi - the number of regular expressions.

setTabSize

public void setTabSize(int tabsiz)
Sets Tab Size option. Default is 8.

Parameters:
tabsiz - the int value that specifies tab sizes. Tabs are expanded for the Ignore Field.

setEOLOption

public void setEOLOption(java.lang.String eolopt)
Sets Write EOLs option for Saved files. Default is the format of the operating environment.

Parameters:
eolopt - the String value of "DOS", "MacOS" or "Unix" specifies the format for writing End-Of-Lines in Saved Files.

setEOLAutoMode

public void setEOLAutoMode(boolean sam)
Sets the EOL AutoMode.

Parameters:
sam - the boolean value for EOL auto-mode.