appli.diff
Class jdiff

java.lang.Object
  extended byappli.diff.jdiff

public class jdiff
extends java.lang.Object

Comparison of C/C++/JAVA files, or directory trees. The comparison is made independently of the file formatting, due to the interal usage of a source beautifier. The full output displays files being in oly one directory, and, for the files common to both trees, the modifications to apply to have the first file identical to the second one.

Version:
1.0 Dec 2003
Author:
Marc Wenger/CDS

Field Summary
private static boolean onlyDirDiffOutput
           
private static boolean recurse
           
private static boolean silentMode
           
 
Constructor Summary
jdiff()
           
 
Method Summary
private static void beautify(ASFormatter form, java.io.File file)
          Beautify a file.
private static TextBuffer beautify(ASFormatter form, TextBuffer txt, java.util.ArrayList lines)
           
private static int blkLength(java.util.ArrayList lines, int lineNum, int blklen)
           
static java.util.ArrayList compareDirectories(java.lang.String dir1, java.lang.String dir2, java.lang.String[] extensions)
          Compare two directories
private static SimpleDiff computeDiffs(java.io.File f1, java.io.File f2)
          Compute the differences between two files (TextBuffers)
private static ASFormatter createBeautifier()
          Initialize options for the beautifier
private static void displayDiffs(SimpleDiff d, java.io.File f1, java.io.File f2)
           
private static void exit(boolean hasDiffs)
          Exit according to the existence of differences
private static void exit(int n)
          Exits with a status
private static int linePos(java.util.ArrayList lines, int lineNum)
           
static void main(java.lang.String[] args)
          Main programme.
private static void println()
          Prints a newline out under the control of -s option
private static void println(java.lang.String str)
          Prints a line out under the control of -s option
private static void usage()
          Display the programme usage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

silentMode

private static boolean silentMode

onlyDirDiffOutput

private static boolean onlyDirDiffOutput

recurse

private static boolean recurse
Constructor Detail

jdiff

public jdiff()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Main programme.

Parameters:
args - command line arguments
Throws:
java.io.IOException - Description

println

private static void println(java.lang.String str)
Prints a line out under the control of -s option

Parameters:
str - the string to print out

println

private static void println()
Prints a newline out under the control of -s option


exit

private static void exit(int n)
Exits with a status

Parameters:
n - status value

exit

private static void exit(boolean hasDiffs)
Exit according to the existence of differences

Parameters:
hasDiffs - true if there are differences

createBeautifier

private static ASFormatter createBeautifier()
Initialize options for the beautifier

Returns:
an ASFormatter object

beautify

private static void beautify(ASFormatter form,
                             java.io.File file)
Beautify a file. Write the output on stdout

Parameters:
form - ASFormatter object already initialized
file - File object

beautify

private static TextBuffer beautify(ASFormatter form,
                                   TextBuffer txt,
                                   java.util.ArrayList lines)

compareDirectories

public static java.util.ArrayList compareDirectories(java.lang.String dir1,
                                                     java.lang.String dir2,
                                                     java.lang.String[] extensions)
                                              throws java.io.IOException,
                                                     java.lang.IllegalArgumentException
Compare two directories

Parameters:
dir1 - first directory. It must be an absolute path
dir2 - second directory. It must be an absolute path
extensions - an array of Strings containing the extensions like ".java"
Returns:
an arrayList with three arrays as objects: files in the first tree, files in the second tree, files in both trees
Throws:
java.io.IOException
java.lang.IllegalArgumentException

computeDiffs

private static SimpleDiff computeDiffs(java.io.File f1,
                                       java.io.File f2)
Compute the differences between two files (TextBuffers)

Parameters:
f1 - first File for the comparison
f2 - second File for the comparison
Returns:
the diff object

displayDiffs

private static void displayDiffs(SimpleDiff d,
                                 java.io.File f1,
                                 java.io.File f2)
                          throws java.io.IOException
Throws:
java.io.IOException

linePos

private static int linePos(java.util.ArrayList lines,
                           int lineNum)

blkLength

private static int blkLength(java.util.ArrayList lines,
                             int lineNum,
                             int blklen)

usage

private static void usage()
Display the programme usage. And exits