JLibDiff
Class SJDiff

java.lang.Object
  |
  +--JLibDiff.SJDiff
All Implemented Interfaces:
JLibDiff.define, JLibDiff.HunkVisitable, java.io.Serializable
Direct Known Subclasses:
TextDiff

public class SJDiff
extends java.lang.Object
implements JLibDiff.define, JLibDiff.HunkVisitable, java.io.Serializable

A modified implimentation of JLibDiff.diff. This version copies most of the code from JLibDiff.diff, but changes addes a method to allow a diff to be build from TextLineReader objects.

See Also:
Serialized Form

Field Summary
(package private)  java.lang.String msEndOfLine
           
(package private)  java.util.Vector v
           
 
Fields inherited from interface JLibDiff.define
DELETE, INSERT, MAXLINES, ORIGIN
 
Constructor Summary
SJDiff()
          Allocates a new diff containing no Hunks.
SJDiff(JLibDiff.diff d)
          Build SJDiff from passed in diff.
SJDiff(java.lang.String s1, java.lang.String s2)
          Allocates a new diff which contains Hunks corresponding to the difference between the two files passed in arguments.
SJDiff(java.util.Vector vec)
          Constructs a new diff with the passed-in Vector as the underlying Vector of "hunk"s.
 
Method Summary
 void accept(JLibDiff.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 diffByteArray(byte[] current, byte[] newFile)
          Builds this diff from the two byte arrays, assuming that the byte arrays are text files in byte form.
 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.
 void diffTextLineIterator(TextLineIterator current, TextLineIterator newFile)
          Builds this diff from the two TextLineIterator objects.
 void diffTextLineReader(TextLineReader current, TextLineReader newFile)
          Builds this diff from the two TextLineReader objects.
 java.util.Vector getHunk()
          Returns a vector containing Hunks.
private static java.util.Vector getHunk(JLibDiff.edit start, char[] A, char[] B)
           
private static java.util.Vector getHunk(JLibDiff.edit start, char[] A, char[] B, java.lang.String sEOL)
           
private static java.util.Vector getHunk(JLibDiff.edit start, java.lang.String[] A, java.lang.String[] B)
           
private static java.util.Vector getHunk(JLibDiff.edit start, java.lang.String[] A, java.lang.String[] B, java.lang.String sEOL)
           
 java.util.Vector getUnderlyingVector()
          Save Hunks with RCS format at the specified file.
 JLibDiff.Hunk hunkAt(int i)
          Return the hunk at the specified index.
private  void makeDiff(java.lang.String[] A, java.lang.String[] B, int m, int n)
          Internal method, called by diffTextLineReader(), diffByteArray(), and diffBuffer() to build this diff.
 int numberOfHunk()
          Returns the number of hunks in the vector.
 void print()
          Print Hunks with normal format.
 void setEndOfLine(java.lang.String s)
           
 void supressEndOfLine()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

v

java.util.Vector v

msEndOfLine

java.lang.String msEndOfLine
Constructor Detail

SJDiff

public SJDiff()
Allocates a new diff containing no Hunks.


SJDiff

public SJDiff(JLibDiff.diff d)
Build SJDiff from passed in diff.


SJDiff

public SJDiff(java.util.Vector vec)
Constructs a new diff with the passed-in Vector as the underlying Vector of "hunk"s. This constructor is provided so that the underlying vector can be serialized and then used to re-construct the class.


SJDiff

public SJDiff(java.lang.String s1,
              java.lang.String s2)
       throws java.io.IOException
Allocates a new diff which contains Hunks corresponding to the difference between the two files passed in arguments.

Parameters:
s1 - first file to compare.
s2 - second file to compare.
Method Detail

setEndOfLine

public void setEndOfLine(java.lang.String s)

supressEndOfLine

public void supressEndOfLine()

getHunk

public java.util.Vector getHunk()
Returns a vector containing Hunks.


numberOfHunk

public int numberOfHunk()
Returns the number of hunks in the vector.


hunkAt

public JLibDiff.Hunk hunkAt(int i)
Return the hunk at the specified index.

Parameters:
i - index of the hunk that will be returned.

accept

public void accept(JLibDiff.HunkVisitor visitor)
Accept a visitor in order to visit the collection of hunks.

Specified by:
accept in interface JLibDiff.HunkVisitable
Parameters:
visitor - the HunkVisitor.

diffFile

public void diffFile(java.lang.String s1,
                     java.lang.String s2)
              throws java.io.IOException
Compares two files and updates the vector of Hunks.

Parameters:
s1 - first file to compare.
s2 - second file to compare.
java.io.IOException

diffBuffer

public void diffBuffer(java.io.BufferedReader in,
                       java.io.BufferedReader inn)
                throws java.io.IOException
Compares two BufferedReaders and updates the vector of Hunks.

Parameters:
in - first BufferedReader to compare.
inn - second BufferedReader to compare.
java.io.IOException

diffByteArray

public void diffByteArray(byte[] current,
                          byte[] newFile)
                   throws java.io.IOException,
                          EndOfSourceException
Builds this diff from the two byte arrays, assuming that the byte arrays are text files in byte form.

java.io.IOException
EndOfSourceException

diffTextLineReader

public void diffTextLineReader(TextLineReader current,
                               TextLineReader newFile)
                        throws java.io.IOException,
                               EndOfSourceException
Builds this diff from the two TextLineReader objects.

java.io.IOException
EndOfSourceException

diffTextLineIterator

public void diffTextLineIterator(TextLineIterator current,
                                 TextLineIterator newFile)
                          throws java.io.IOException,
                                 EndOfSourceException
Builds this diff from the two TextLineIterator objects.

java.io.IOException
EndOfSourceException

makeDiff

private void makeDiff(java.lang.String[] A,
                      java.lang.String[] B,
                      int m,
                      int n)
               throws java.io.IOException
Internal method, called by diffTextLineReader(), diffByteArray(), and diffBuffer() to build this diff.

java.io.IOException

diffString

public void diffString(java.lang.String s1,
                       java.lang.String s2)
                throws java.io.IOException
Compares two strings and updates the vector of Hunks.

Parameters:
s1 - first string to compare.
s2 - second string to compare.
java.io.IOException

getHunk

private static java.util.Vector getHunk(JLibDiff.edit start,
                                        java.lang.String[] A,
                                        java.lang.String[] B)
                                 throws java.io.IOException
java.io.IOException

getHunk

private static java.util.Vector getHunk(JLibDiff.edit start,
                                        java.lang.String[] A,
                                        java.lang.String[] B,
                                        java.lang.String sEOL)
                                 throws java.io.IOException
java.io.IOException

getHunk

private static java.util.Vector getHunk(JLibDiff.edit start,
                                        char[] A,
                                        char[] B)
                                 throws java.io.IOException
java.io.IOException

getHunk

private static java.util.Vector getHunk(JLibDiff.edit start,
                                        char[] A,
                                        char[] B,
                                        java.lang.String sEOL)
                                 throws java.io.IOException
java.io.IOException

print

public void print()
Print Hunks with normal format.


getUnderlyingVector

public java.util.Vector getUnderlyingVector()
Save Hunks with RCS format at the specified file.



Copyright 2003 Soucejammer project.