Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
InlineDiffDisplayer | 55 | 0 | - | 0 | 0 |
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 an in-line diff. An in-line diff is made of a list of chunks, each marked as added, | |
29 | * removed or unmodified. For instance, if changes are computed at word level then you could have this in-line diff: | |
30 | * | |
31 | * <pre> | |
32 | * {@code the <del>quick</del><ins>sick</ins> brown fox} | |
33 | * </pre> | |
34 | * | |
35 | * At character level the diff looks a bit different: | |
36 | * | |
37 | * <pre> | |
38 | * {@code the <del>qu</del><ins>s</ins>ick brown fox} | |
39 | * </pre> | |
40 | * | |
41 | * In this case the first chunk is "the ", an unmodified chunk, made of 4 characters and the second chunk is "qu", a | |
42 | * removed chunk, made of 2 characters. An in-line diff can be displayed either as you've seen above, mixing added and | |
43 | * removed chunks in one line, or it can be displayed on two lines, one showing the removed chunks and the other the | |
44 | * added chunks: | |
45 | * | |
46 | * <pre> | |
47 | * {@code the <del>quick</del> brown fox | |
48 | * the <ins>sick</ins> brown fox} | |
49 | * </pre> | |
50 | * | |
51 | * @version $Id: 0f0a11a6c0853278c17a183b7e6f6f2f49737d42 $ | |
52 | * @since 4.1RC1 | |
53 | */ | |
54 | @Role | |
55 | public interface InlineDiffDisplayer | |
56 | { | |
57 | /** | |
58 | * Displays the given diff result as an in-line diff. An in-line diff is a list of group of elements, each group | |
59 | * being marked as added, removed or unmodified. The in-line diff includes all the elements from the previous and | |
60 | * the next version that were compared to produce the diff: | |
61 | * <ul> | |
62 | * <li>the elements found in the previous version but not in the next version are marked at removed</li> | |
63 | * <li>the elements from the next version that are not present in the previous version are marked as added</li> | |
64 | * <li>the rest of the elements that are found in both versions are marked as unmodified.</li> | |
65 | * </ul> | |
66 | * If changes are computed at character level, i.e. the type of elements that are compared is {@link Character}, | |
67 | * then the in-line diff between "the quick fox" and "the sick fox" is: | |
68 | * | |
69 | * <pre> | |
70 | * {@code the <del>qu</del><ins>s</ins>ick fox} | |
71 | * </pre> | |
72 | * | |
73 | * and is made of 4 groups of {@link Character}s: "the " unmodified, "qu" removed, "s" added and "ick fox" | |
74 | * unmodified. | |
75 | * | |
76 | * @param <E> the type of elements that are add/remove/modified in the given diff result (specifies the granularity | |
77 | * level of changes) | |
78 | * @param diffResult the diff result to be displayed | |
79 | * @return the list of chunks that form the in-line diff | |
80 | */ | |
81 | <E> List<InlineDiffChunk<E>> display(DiffResult<E> diffResult); | |
82 | } |