Main Page | Class Hierarchy | Class List | File List | Class Members

JLibDiff::diff Class Reference

List of all members.

Public Member Functions

 diff (System.String s1, System.String s2)
virtual System.Collections.ArrayList getHunk ()
virtual int numberOfHunk ()
virtual Hunk hunkAt (int i)
virtual void accept (HunkVisitor visitor)
virtual void diffFile (System.String s1, System.String s2)
virtual void diffBuffer (System.IO.StreamReader in_Renamed, System.IO.StreamReader inn)
virtual void diffString (System.String s1, System.String s2)
virtual void print ()

Detailed Description

<summary> 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:

<blockquote>

	        diff d = new diff(file1,file2);
	    
</blockquote>

which is equivalent to:

<blockquote>

	        diff d = new diff();
	        d.diffFile(file1,file2);
	    
</blockquote>

To compare two BufferedReaders or two String we have to instanciate as follows:

<blockquote>

	        diff d = new diff();
	        d.diffBuffer(BufferedReader1,BufferedReader2);
	    
</blockquote>

or:

<blockquote>

	        diff d = new diff();
	        d.diffString(String1,String2);
	    
</blockquote>

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:

<blockquote>

	   	diff d=new diff(args[0],args[1]);
	   	d.print();
	        d.save("diff.txt");
	    
</blockquote>

Example using BufferedReader and ED_format:

<blockquote>

 
	   	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");
	    
</blockquote>

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.

<blockquote>

 
	        Vector v=d.getHunk();
	        for(Enumeration e=v.element();e.hasMoreElements(); )
	          {
	            System.out.print(((Hunk)e.nextElement()).convert());
	          } 
	    
</blockquote>

or:

<blockquote>

	        diff d = new diff(file1,file2); 
	        for(int i=0; i<d.numberOfHunk(); i++){
	           Object k=d.hunkAt(i);
	           if(k instanceof Hunk)
	             System.out.print(k.convert());
	         }
	    
</blockquote>

See also:
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() </summary>

Definition at line 82 of file diff.cs.


The documentation for this class was generated from the following file:
Generated on Mon May 8 22:07:28 2006 by  doxygen 1.3.9.1