bmsi.util
Class DiffPrint.Base

java.lang.Object
  extended by bmsi.util.DiffPrint.Base
Direct Known Subclasses:
DiffPrint.ContextPrint, DiffPrint.EdPrint, DiffPrint.NormalPrint
Enclosing class:
DiffPrint

public abstract static class DiffPrint.Base
extends Object

A Base class for printing edit scripts produced by Diff. This class divides the change list into "hunks", and calls print_hunk for each hunk. Various utility methods are provided as well.


Field Summary
protected  int deletes
           
protected  Object[] file0
          Set to the lines of the files being compared.
protected  Object[] file1
          Set to the lines of the files being compared.
protected  int first0
           
protected  int first1
           
protected  bmsi.util.UnaryPredicate ignore
          Set to ignore certain kinds of lines when printing an edit script.
protected  int inserts
           
protected  int last0
           
protected  int last1
           
protected  PrintWriter outfile
           
 
Constructor Summary
protected DiffPrint.Base(Object[] a, Object[] b)
           
 
Method Summary
protected  void analyze_hunk(Diff.change hunk)
          Look at a hunk of edit script and report the range of lines in each file that it applies to.
static char change_letter(int inserts, int deletes)
           
protected  Diff.change hunkfun(Diff.change hunk)
          Called with the tail of the script and returns the last link that belongs together with the start of the tail.
protected  void print_1_line(String pre, Object linbuf)
           
 void print_header(String filea, String fileb)
          Called to print the script header which identifies the files compared.
protected abstract  void print_hunk(Diff.change hunk)
           
protected  void print_number_range(char sepchar, int a, int b)
          Print a pair of line numbers with SEPCHAR, translated for file FILE.
 void print_script(Diff.change script)
          Divide SCRIPT into pieces by calling HUNKFUN and print each piece with PRINTFUN.
 void setOutput(Writer wtr)
           
protected  void setupOutput()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outfile

protected PrintWriter outfile

ignore

protected bmsi.util.UnaryPredicate ignore
Set to ignore certain kinds of lines when printing an edit script. For example, ignoring blank lines or comments.


file0

protected Object[] file0
Set to the lines of the files being compared.


file1

protected Object[] file1
Set to the lines of the files being compared.


first0

protected int first0

last0

protected int last0

first1

protected int first1

last1

protected int last1

deletes

protected int deletes

inserts

protected int inserts
Constructor Detail

DiffPrint.Base

protected DiffPrint.Base(Object[] a,
                         Object[] b)
Method Detail

setOutput

public void setOutput(Writer wtr)

setupOutput

protected void setupOutput()

print_script

public void print_script(Diff.change script)
Divide SCRIPT into pieces by calling HUNKFUN and print each piece with PRINTFUN. Both functions take one arg, an edit script. PRINTFUN takes a subscript which belongs together (with a null link at the end) and prints it.


hunkfun

protected Diff.change hunkfun(Diff.change hunk)
Called with the tail of the script and returns the last link that belongs together with the start of the tail.


analyze_hunk

protected void analyze_hunk(Diff.change hunk)
Look at a hunk of edit script and report the range of lines in each file that it applies to. HUNK is the start of the hunk, which is a chain of `struct change'. The first and last line numbers of file 0 are stored in *FIRST0 and *LAST0, and likewise for file 1 in *FIRST1 and *LAST1. Note that these are internal line numbers that count from 0. If no lines from file 0 are deleted, then FIRST0 is LAST0+1. Also set *DELETES nonzero if any lines of file 0 are deleted and set *INSERTS nonzero if any lines of file 1 are inserted. If only ignorable lines are inserted or deleted, both are set to 0.


print_header

public void print_header(String filea,
                         String fileb)
Called to print the script header which identifies the files compared. The default does nothing (except set output to system.out if not otherwise set). Derived style classes can override to print the files compared in the format for that style.


print_hunk

protected abstract void print_hunk(Diff.change hunk)

print_1_line

protected void print_1_line(String pre,
                            Object linbuf)

print_number_range

protected void print_number_range(char sepchar,
                                  int a,
                                  int b)
Print a pair of line numbers with SEPCHAR, translated for file FILE. If the two numbers are identical, print just one number. Args A and B are internal line numbers. We print the translated (real) line numbers.


change_letter

public static char change_letter(int inserts,
                                 int deletes)


Copyright © 2004-2013. All Rights Reserved.