@Deprecated public class

DiffUtils

extends Object
java.lang.Object
   ↳ com.atlassian.confluence.util.DiffUtils

This class is deprecated.
since 4.0. Not used. Please use ConfluenceDiff instead.

Summary

Constants
byte DIFF_MODE_ADD
byte DIFF_MODE_CHANGE_ADD
byte DIFF_MODE_CHANGE_DELETE
byte DIFF_MODE_DELETE
byte DIFF_MODE_NONE
String STYLE_ADDED
String STYLE_DELETED
String STYLE_ERROR
String STYLE_NONE
byte WORD_DIFF_MAX maximum percentage of words to diff in a line.
Public Constructors
DiffUtils()
Public Methods
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)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final byte DIFF_MODE_ADD

Constant Value: 0 (0x00000000)

public static final byte DIFF_MODE_CHANGE_ADD

Constant Value: 3 (0x00000003)

public static final byte DIFF_MODE_CHANGE_DELETE

Constant Value: 2 (0x00000002)

public static final byte DIFF_MODE_DELETE

Constant Value: 1 (0x00000001)

public static final byte DIFF_MODE_NONE

Constant Value: -1 (0xffffffff)

public static final String STYLE_ADDED

Constant Value: "diff-added-words"

public static final String STYLE_DELETED

Constant Value: "diff-deleted-words"

public static final String STYLE_ERROR

Constant Value: "differror"

public static final String STYLE_NONE

Constant Value: ""

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

Constant Value: 60 (0x0000003c)

Public Constructors

public DiffUtils ()

Public Methods

public static String diffLine (String orig, String rev)

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
DifferentiationFailedException

public static DiffResult generateDiff (ContentEntityObject originalPage, ContentEntityObject revisedPage)

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
DifferentiationFailedException

public static byte getDiffMode ()

public static Object[] loadPage (ContentEntityObject page)

public static String mergeChanges (String originalPage, String revisionA, String revisionB)

Returns
  • null if the merge was unsuccessful

public static void setDiffMode (byte mode)