| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--JLibDiff.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.
 
to generate a file of difference, one can instanciate as follows the class diff:
     diff d = new diff(file1,file2);
 which is equivalent to:
     diff d = new diff();
     d.diffFile(file1,file2);
 To compare two BufferedReaders or two String we have to instanciate as follows:
     diff d = new diff();
     d.diffBuffer(BufferedReader1,BufferedReader2);
 or:
     diff d = new diff();
     d.diffString(String1,String2);
 
 The class diff includes methods for examining, printing
 or saveing  blocks of difference: (Hunks).
 Here are some more examples of how diff can be used:
 
	diff d=new diff(args[0],args[1]);
	d.print();
     d.save("diff.txt");
 Example using BufferedReader and ED_format:
	BufferedReader in=new BufferedReader(new FileReader(args[0]));
	BufferedReader inn=new BufferedReader(new FileReader(args[1]));
	diff d = new diff();
	d.diffBuffer(in,inn);
	d.print_ED();
	d.save_ED("diff.txt");
 To go throw the list of Hunks we can choose between an Enumeration or a loop by spesifyng index in the vector to get at each time the corresponding Hunk.
     Vector v=d.getHunk();
     for(Enumeration e=v.element();e.hasMoreElements(); )
       {
         System.out.print(((Hunk)e.nextElement()).convert());
       }
 or:
     diff d = new diff(file1,file2);
     for(int i=0; i
diff.diff#getHunk(), 
diff.diff#hunkAt(), 
diff.diff#numberOfHunk(), 
diff.diff#print(), 
diff.diff#print_ED(), 
diff.diff#print_RCS(), 
diff.diff#save(), 
diff.diff#save_ED(), 
diff.diff#save_RCS(), 
Serialized Form| Field Summary | |
| (package private)  java.lang.String | msEOL | 
| (package private)  java.util.Vector | v | 
| Fields inherited from interface JLibDiff.define | 
| DELETE, INSERT, MAXLINES, ORIGIN | 
| Constructor Summary | |
| diff()Allocates a new diffcontaining no Hunks. | |
| diff(java.lang.String s1,
     java.lang.String s2)Allocates a new diffwhich contains Hunks corresponding
 to the difference between the two files passed in arguments. | |
| Method Summary | |
|  void | accept(HunkVisitor visitor)Accept a visitor in order to visit the collection of hunks. | 
|  void | diffBuffer(java.io.BufferedReader in,
           java.io.BufferedReader inn)Compares two BufferedReaders and updates the vector of Hunks. | 
|  void | diffFile(java.lang.String s1,
         java.lang.String s2)Compares two files and updates the vector of Hunks. | 
|  void | diffString(java.lang.String s1,
           java.lang.String s2)Compares two strings and updates the vector of Hunks. | 
|  java.util.Vector | getHunk()Returns a vector containing Hunks. | 
| private static java.util.Vector | getHunk(edit start,
        char[] A,
        char[] B,
        java.lang.String sEOL) | 
| private static java.util.Vector | getHunk(edit start,
        java.lang.String[] A,
        java.lang.String[] B,
        java.lang.String sEOL) | 
|  Hunk | hunkAt(int i)Return the hunk at the specified index. | 
|  int | numberOfHunk()Returns the number of hunks in the vector. | 
|  void | print()Print Hunks with normal format. | 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
java.util.Vector v
java.lang.String msEOL
| Constructor Detail | 
public diff()
diff containing no Hunks.
public diff(java.lang.String s1,
            java.lang.String s2)
     throws java.io.IOException
diff which contains Hunks corresponding
 to the difference between the two files passed in arguments.
s1 - first file to compare.s2 - second file to compare.| Method Detail | 
public java.util.Vector getHunk()
public int numberOfHunk()
public Hunk hunkAt(int i)
i - index of the hunk that will be returned.public void accept(HunkVisitor visitor)
accept in interface HunkVisitablevisitor - the HunkVisitor.
public void diffFile(java.lang.String s1,
                     java.lang.String s2)
              throws java.io.IOException
s1 - first file to compare.s2 - second file to compare.
java.io.IOException
public void diffBuffer(java.io.BufferedReader in,
                       java.io.BufferedReader inn)
                throws java.io.IOException
in - first BufferedReader to compare.inn - second BufferedReader to compare.
java.io.IOException
public void diffString(java.lang.String s1,
                       java.lang.String s2)
                throws java.io.IOException
s1 - first string to compare.s2 - second string to compare.
java.io.IOException
private static java.util.Vector getHunk(edit start,
                                        java.lang.String[] A,
                                        java.lang.String[] B,
                                        java.lang.String sEOL)
                                 throws java.io.IOException
java.io.IOException
private static java.util.Vector getHunk(edit start,
                                        char[] A,
                                        char[] B,
                                        java.lang.String sEOL)
                                 throws java.io.IOException
java.io.IOExceptionpublic void print()
| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||