SourceJammer 1.2.0.1 May 20, 2002
Copyright (c) 2001, 2002 Robert MacGrogan

JLibDiff
Class SJDiff

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

public class SJDiff
extends java.lang.Object
implements define, 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

Fields inherited from interface JLibDiff.define
DELETE, INSERT, MAXLINES, ORIGIN
 
Constructor Summary
SJDiff()
          Allocates a new diff containing no Hunks.
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(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.
 java.util.Vector getUnderlyingVector()
          Save Hunks with RCS format at the specified file.
 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.
 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
 

Constructor Detail

SJDiff

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

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 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(HunkVisitor visitor)
Accept a visitor in order to visit the collection of hunks.
Specified by:
accept in interface 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.

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.

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.

diffTextLineReader

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

diffTextLineIterator

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

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.

print

public void print()
Print Hunks with normal format.

getUnderlyingVector

public java.util.Vector getUnderlyingVector()
Save Hunks with RCS format at the specified file.
Parameters:
file - file in which Hunks will be saved.

SourceJammer 1.2.0.1 May 20, 2002
Copyright (c) 2001, 2002 Robert MacGrogan