org.xwiki.diff.display
Interface UnifiedDiffDisplayer

All Known Implementing Classes:
DefaultUnifiedDiffDisplayer

@Role
public interface UnifiedDiffDisplayer

Displays a DiffResult as a unified diff. The unified diff consists in a sequence of blocks, each having elements marked as either added or removed, padded with unmodified elements that put changes in context.

Since:
4.1RC1

Method Summary
<E,F> List<UnifiedDiffBlock<E,F>>
display(DiffResult<E> diffResult)
          Displays the given diff result as an unified diff using the default configuration.
<E,F> List<UnifiedDiffBlock<E,F>>
display(DiffResult<E> diffResult, UnifiedDiffConfiguration<E,F> config)
          Displays the given diff result as an unified diff using the provided configuration.
<E,F> UnifiedDiffConfiguration<E,F>
getDefaultConfiguration()
           
 

Method Detail

getDefaultConfiguration

<E,F> UnifiedDiffConfiguration<E,F> getDefaultConfiguration()
Type Parameters:
E - the type of elements that are compared to produce the diff
F - the type of sub-elements that can be compared to produce an in-line diff when an element is modified
Returns:
the default configuration for this displayer

display

<E,F> List<UnifiedDiffBlock<E,F>> display(DiffResult<E> diffResult)
Displays the given diff result as an unified diff using the default configuration.

Type Parameters:
E - the type of elements that are compared to produce the diff
F - the type of sub-elements that can be compared to produce an in-line diff when an element is modified
Parameters:
diffResult - the diff result
Returns:
the list of blocks that form the unified diff
See Also:
display(DiffResult, UnifiedDiffConfiguration)

display

<E,F> List<UnifiedDiffBlock<E,F>> display(DiffResult<E> diffResult,
                                          UnifiedDiffConfiguration<E,F> config)
Displays the given diff result as an unified diff using the provided configuration. An unified diff consists in a list of blocks, each block grouping changes that are close to each other. The distance between two changes in a block is less than 2 * context size, where context size represents the number of unmodified elements to include before and after a change in order to place that change in context.

If the elements can be split in sub-elements, i.e. if a splitter is provided through the configuration, then the unified diff displays also the changes inside the modified elements.

If changes are computed at the line level in a text, i.e. the elements that are compared to produce the diff are lines of text, and a word splitter is provided through configuration then the following is a block from a unified diff:

 @@ -81,5 +85,5 @@
  first line of context
  another unmodified line
 -this line <del>has been removed</del>
 +this line <ins>replaced the previous line</ins>
  close the block with unmodified lines
  last line of context
 

Type Parameters:
E - the type of elements that were compared to produce the diff
F - the type of sub-elements that can be compared to produce an in-line diff when an element is modified
Parameters:
diffResult - the diff result
config - the configuration
Returns:
the list of blocks that form the unified diff