1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.diff.display

File UnifiedDiffDisplayer.java

 

Code metrics

0
0
0
1
86
11
0
-
-
0
-

Classes

Class Line # Actions
UnifiedDiffDisplayer 36 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.diff.display;
21   
22    import java.util.List;
23   
24    import org.xwiki.component.annotation.Role;
25    import org.xwiki.diff.DiffResult;
26   
27    /**
28    * Displays a {@link DiffResult} as a <a href="http://en.wikipedia.org/wiki/Diff#Unified_format">unified diff</a>. The
29    * unified diff consists in a sequence of blocks, each having elements marked as either added or removed, padded with
30    * unmodified elements that put changes in context.
31    *
32    * @version $Id: 0254f01ad5e93c4239958c1a049a3c8daabd5ce5 $
33    * @since 4.1RC1
34    */
35    @Role
 
36    public interface UnifiedDiffDisplayer
37    {
38    /**
39    * @param <E> the type of elements that are compared to produce the diff
40    * @param <F> the type of sub-elements that can be compared to produce an in-line diff when an element is modified
41    * @return the default configuration for this displayer
42    */
43    <E, F> UnifiedDiffConfiguration<E, F> getDefaultConfiguration();
44   
45    /**
46    * Displays the given diff result as an unified diff using the default configuration.
47    *
48    * @param <E> the type of elements that are compared to produce the diff
49    * @param <F> the type of sub-elements that can be compared to produce an in-line diff when an element is modified
50    * @param diffResult the diff result
51    * @return the list of blocks that form the unified diff
52    * @see #display(DiffResult, UnifiedDiffConfiguration)
53    */
54    <E, F> List<UnifiedDiffBlock<E, F>> display(DiffResult<E> diffResult);
55   
56    /**
57    * Displays the given diff result as an unified diff using the provided configuration. An unified diff consists in a
58    * list of blocks, each block grouping changes that are close to each other. The distance between two changes in a
59    * block is less than {@code 2 * context size}, where context size represents the number of unmodified elements to
60    * include before and after a change in order to place that change in context.
61    * <p>
62    * If the elements can be split in sub-elements, i.e. if a splitter is provided through the configuration, then the
63    * unified diff displays also the changes inside the modified elements.
64    * <p>
65    * If changes are computed at the line level in a text, i.e. the elements that are compared to produce the diff are
66    * lines of text, and a word splitter is provided through configuration then the following is a block from a unified
67    * diff:
68    *
69    * <pre>
70    * {@code @@ -81,5 +85,5 @@
71    * first line of context
72    * another unmodified line
73    * -this line <del>has been removed</del>
74    * +this line <ins>replaced the previous line</ins>
75    * close the block with unmodified lines
76    * last line of context}
77    * </pre>
78    *
79    * @param <E> the type of elements that were compared to produce the diff
80    * @param <F> the type of sub-elements that can be compared to produce an in-line diff when an element is modified
81    * @param diffResult the diff result
82    * @param config the configuration
83    * @return the list of blocks that form the unified diff
84    */
85    <E, F> List<UnifiedDiffBlock<E, F>> display(DiffResult<E> diffResult, UnifiedDiffConfiguration<E, F> config);
86    }