Package com.jalios.util.diff
Class Diff
java.lang.Object
com.jalios.util.diff.Diff
The Diff class compares two files. It compares also two
BufferedReaders or two strings.
after the comparison the vector will represents a list of hunk
corresponding with blocks of difference.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddiffBuffer(BufferedReader in, BufferedReader inn) Compares two BufferedReaders and updates the vector of Hunks.voidCompares two files and updates the vector of Hunks.voiddiffString(String s1, String s2) Compares two strings and updates the vector of Hunks.getHunk()Returns a vector containing Hunks.iterateHunkBuffer(BufferedReader reader, String stuffBeforeDelete, String stuffAfterDelete, String stuffBeforeAdd, String stuffAfterAdd, String stuffBefore, String stuffAfter, boolean printline, boolean escapeHTML, boolean hunkString) Iterate over a the hunks to print a readable representation.iterateHunkString(String str, String stuffBeforeDelete, String stuffAfterDelete, String stuffBeforeAdd, String stuffAfterAdd, boolean escapeHTML) Iterate over a the hunks to print a readable representation.static voidvoidprint()Print Hunks with normal format.
-
Field Details
-
MAXLINES
public static final int MAXLINES- See Also:
-
ORIGIN
public static final int ORIGIN- See Also:
-
INSERT
public static final int INSERT- See Also:
-
DELETE
public static final int DELETE- See Also:
-
-
Constructor Details
-
Diff
public Diff()Allocates a newdiffcontaining no Hunks. -
Diff
Allocates a newdiffwhich contains Hunks corresponding to the difference between the two files passed in arguments.- Parameters:
s1- first file to compare.s2- second file to compare.- Throws:
IOException
-
-
Method Details
-
main
- Throws:
Exception
-
iterateHunkString
public String iterateHunkString(String str, String stuffBeforeDelete, String stuffAfterDelete, String stuffBeforeAdd, String stuffAfterAdd, boolean escapeHTML) throws Exception Iterate over a the hunks to print a readable representation.- Parameters:
str- The original string to printstuffBeforeDelete- String to add before deleted hunk.stuffAfterDelete- String to add after deleted hunk.stuffBeforeAdd- String to add before added hunk.stuffAfterAdd- String to add after added hunk.escapeHTML- should escape html ?- Returns:
- The result string
- Throws:
Exception
-
iterateHunkBuffer
public String iterateHunkBuffer(BufferedReader reader, String stuffBeforeDelete, String stuffAfterDelete, String stuffBeforeAdd, String stuffAfterAdd, String stuffBefore, String stuffAfter, boolean printline, boolean escapeHTML, boolean hunkString) throws Exception Iterate over a the hunks to print a readable representation.- Parameters:
reader- The original buffer to printstuffBeforeDelete- String to add before deleted hunk.stuffAfterDelete- String to add after deleted hunk.stuffBeforeAdd- String to add before added hunk.stuffAfterAdd- String to add after added hunk.stuffBefore- String to add before line.stuffAfter- String to add after line.printline- should print the line number ?escapeHTML- should escape html ?hunkString- should diff each line of hunks ?- Returns:
- The result string
- Throws:
Exception
-
getHunk
Returns a vector containing Hunks. -
diffFile
Compares two files and updates the vector of Hunks.- Parameters:
s1- first file to compare.s2- second file to compare.- Throws:
IOException
-
diffBuffer
Compares two BufferedReaders and updates the vector of Hunks.- Parameters:
in- first BufferedReader to compare.inn- second BufferedReader to compare.- Throws:
IOException
-
diffString
Compares two strings and updates the vector of Hunks.- Parameters:
s1- first string to compare.s2- second string to compare.- Throws:
IOException
-
print
public void print()Print Hunks with normal format.
-