calhoun.util
Class FileDiff

java.lang.Object
  extended by calhoun.util.FileDiff

public class FileDiff
extends java.lang.Object

Computes the 'diff' difference between two files. By default, whitespace in the files is ignored.


Constructor Summary
FileDiff(java.io.File first, java.io.File second)
          Constructor takes 2 Files - opens the files using UTF-8 encoding.
FileDiff(java.io.Reader first, java.io.Reader second)
           
FileDiff(java.io.Reader first, java.io.Reader second, boolean closeReaders)
           
FileDiff(java.lang.String first, java.lang.String second)
          Constructor takes 2 file names - opens the files using UTF-8 encoding.
 
Method Summary
 boolean execute()
           
static boolean filesMatch(java.lang.String first, java.lang.String second)
           
 java.lang.String getCommentLineIndicator()
          Gets the comment line indicator string.
 boolean getIgnoreWhitespace()
           
 void setCommentLineIndicator(java.lang.String commentLineIndicator)
          Sets the comment line indicator string.
 void setIgnoreWhitespace(boolean b)
          Sets whether to ignore whitespace.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileDiff

public FileDiff(java.lang.String first,
                java.lang.String second)
         throws java.io.IOException
Constructor takes 2 file names - opens the files using UTF-8 encoding.

Throws:
java.io.IOException

FileDiff

public FileDiff(java.io.File first,
                java.io.File second)
         throws java.io.IOException
Constructor takes 2 Files - opens the files using UTF-8 encoding.

Throws:
java.io.IOException

FileDiff

public FileDiff(java.io.Reader first,
                java.io.Reader second)

FileDiff

public FileDiff(java.io.Reader first,
                java.io.Reader second,
                boolean closeReaders)
Method Detail

filesMatch

public static boolean filesMatch(java.lang.String first,
                                 java.lang.String second)
                          throws java.io.IOException
Throws:
java.io.IOException

setIgnoreWhitespace

public void setIgnoreWhitespace(boolean b)
Sets whether to ignore whitespace. By default, whitespace is ignored.

See Also:
getIgnoreWhitespace()

getIgnoreWhitespace

public boolean getIgnoreWhitespace()
See Also:
setIgnoreWhitespace(boolean)

setCommentLineIndicator

public void setCommentLineIndicator(java.lang.String commentLineIndicator)
Sets the comment line indicator string. If set, lines beginning with this string are not used in the diff comparison.

See Also:
getCommentLineIndicator()

getCommentLineIndicator

public java.lang.String getCommentLineIndicator()
Gets the comment line indicator string.

See Also:
setCommentLineIndicator(java.lang.String)

execute

public boolean execute()
                throws java.io.IOException
Returns:
whether the two files were different.
Throws:
java.io.IOException
See Also:
toString()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a diff-style listing of the differences between the 2 files. If the files were identical, returns the empty string ('').