com.ecyrd.jspwiki
Class DifferenceEngine

java.lang.Object
  |
  +--com.ecyrd.jspwiki.DifferenceEngine

public class DifferenceEngine
extends java.lang.Object

Provides access to making a 'diff' between two Strings. Can be commanded to use a diff program or to use an internal diff.

Author:
Janne Jalkanen, Erik Bunn

Field Summary
static java.lang.String PROP_DIFFCOMMAND
          Determines the command to be used for 'diff'.
 
Constructor Summary
DifferenceEngine(java.util.Properties props, java.lang.String encoding)
          Creates a new DifferenceEngine.
 
Method Summary
 java.lang.String colorizeDiff(java.lang.String diffText)
          Goes through output provided by a diff command and inserts HTML tags to make the result more legible.
 java.lang.String makeDiff(java.lang.String p1, java.lang.String p2)
          Returns a raw, text format diff of its arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_DIFFCOMMAND

public static final java.lang.String PROP_DIFFCOMMAND
Determines the command to be used for 'diff'. This program must be able to output diffs in the unified format. It defaults to 'diff -u %s1 %s2'.

See Also:
Constant Field Values
Constructor Detail

DifferenceEngine

public DifferenceEngine(java.util.Properties props,
                        java.lang.String encoding)
Creates a new DifferenceEngine.

Parameters:
props - The contents of jspwiki.properties
encoding - The character encoding used for making the diff.
Method Detail

makeDiff

public java.lang.String makeDiff(java.lang.String p1,
                                 java.lang.String p2)
Returns a raw, text format diff of its arguments. This diff can then be fed to the colorizeDiff(), below.

See Also:
colorizeDiff(java.lang.String)

colorizeDiff

public java.lang.String colorizeDiff(java.lang.String diffText)
                              throws java.io.IOException
Goes through output provided by a diff command and inserts HTML tags to make the result more legible. Currently colors lines starting with a + green, those starting with - reddish (hm, got to think of color blindness here...).

java.io.IOException