com.atlassian.confluence.util
Class DiffUtils

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

public class DiffUtils
extends java.lang.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 java.lang.String STYLE_ADDED
           
static java.lang.String STYLE_DELETED
           
static java.lang.String STYLE_ERROR
           
static java.lang.String STYLE_NONE
           
static byte WORD_DIFF_MAX
          maximum percentage of words to diff in a line.
 
Constructor Summary
DiffUtils()
           
 
Method Summary
static java.lang.String diffLine(java.lang.String orig, java.lang.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 java.lang.Object[] loadPage(ContentEntityObject page)
           
static java.lang.String mergeChanges(java.lang.String originalPage, java.lang.String revisionA, java.lang.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 java.lang.String STYLE_NONE
See Also:
Constant Field Values

STYLE_ADDED

public static final java.lang.String STYLE_ADDED
See Also:
Constant Field Values

STYLE_DELETED

public static final java.lang.String STYLE_DELETED
See Also:
Constant Field Values

STYLE_ERROR

public static final java.lang.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 java.lang.Object[] loadPage(ContentEntityObject page)

diffLine

public static java.lang.String diffLine(java.lang.String orig,
                                        java.lang.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 java.lang.String mergeChanges(java.lang.String originalPage,
                                            java.lang.String revisionA,
                                            java.lang.String revisionB)
Returns:
null if the merge was unsuccessful


Copyright © 2003-2010 Atlassian. All Rights Reserved.