com.atlassian.confluence.util
Class DiffUtils

java.lang.Object
  extended by com.atlassian.confluence.util.DiffUtils

public class DiffUtils
extends Object


Field Summary
static byte DIFF_MODE_ADD
           
static byte DIFF_MODE_CHANGE_ADD
           
static byte DIFF_MODE_CHANGE_DELETE
           
static byte DIFF_MODE_DELETE
           
static byte DIFF_MODE_NONE
           
static String STYLE_ADDED
           
static String STYLE_DELETED
           
static String STYLE_ERROR
           
static String STYLE_NONE
           
static byte WORD_DIFF_MAX
          maximum percentage of words to diff in a line.
 
Constructor Summary
DiffUtils()
           
 
Method Summary
static String diffLine(String orig, String rev)
          Will perform a diff on two lines.
static DiffResult generateDiff(ContentEntityObject originalPage, ContentEntityObject revisedPage)
          Calculates the difference between two pages and returns the result as HTML.
static byte getDiffMode()
           
static Object[] loadPage(ContentEntityObject page)
           
static String mergeChanges(String originalPage, String revisionA, String revisionB)
           
static void setDiffMode(byte mode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORD_DIFF_MAX

public static final byte WORD_DIFF_MAX
maximum percentage of words to diff in a line. If the percentage of diffed words exceed this number only line diffing is displayed

See Also:
Constant Field Values

DIFF_MODE_NONE

public static final byte DIFF_MODE_NONE
See Also:
Constant Field Values

DIFF_MODE_ADD

public static final byte DIFF_MODE_ADD
See Also:
Constant Field Values

DIFF_MODE_DELETE

public static final byte DIFF_MODE_DELETE
See Also:
Constant Field Values

DIFF_MODE_CHANGE_DELETE

public static final byte DIFF_MODE_CHANGE_DELETE
See Also:
Constant Field Values

DIFF_MODE_CHANGE_ADD

public static final byte DIFF_MODE_CHANGE_ADD
See Also:
Constant Field Values

STYLE_NONE

public static final String STYLE_NONE
See Also:
Constant Field Values

STYLE_ADDED

public static final String STYLE_ADDED
See Also:
Constant Field Values

STYLE_DELETED

public static final String STYLE_DELETED
See Also:
Constant Field Values

STYLE_ERROR

public static final String STYLE_ERROR
See Also:
Constant Field Values
Constructor Detail

DiffUtils

public DiffUtils()
Method Detail

generateDiff

public static DiffResult generateDiff(ContentEntityObject originalPage,
                                      ContentEntityObject revisedPage)
                               throws org.apache.commons.jrcs.diff.DifferentiationFailedException
Calculates the difference between two pages and returns the result as HTML.

The CSS styles used are:

  1. diff-added-lines - section has been added
  2. diff-deleted-lines - section has been removed
  3. diff-snipped - section has not been changed
  4. differror - (rare) used if there is an error

Parameters:
originalPage - The original page
revisedPage - The revised page
Returns:
A DiffResult
Throws:
org.apache.commons.jrcs.diff.DifferentiationFailedException

loadPage

public static Object[] loadPage(ContentEntityObject page)

diffLine

public static String diffLine(String orig,
                              String rev)
                       throws org.apache.commons.jrcs.diff.DifferentiationFailedException
Will perform a diff on two lines. This works similar to the deff above and if I had more time I would like to refactor the methods and merge them. //TODO Refactor the diff methods into one clean method

Parameters:
orig - the original line
rev - the revised line
Returns:
a html diff of the two lines
Throws:
org.apache.commons.jrcs.diff.DifferentiationFailedException

getDiffMode

public static byte getDiffMode()

setDiffMode

public static void setDiffMode(byte mode)

mergeChanges

public static String mergeChanges(String originalPage,
                                  String revisionA,
                                  String revisionB)
Returns:
null if the merge was unsuccessful


Copyright © 2003-2011 Atlassian. All Rights Reserved.