Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
ComposedAlteredContent | 33 | 10 | 0% | 5 | 15 |
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.annotation.internal.content; | |
21 | ||
22 | import org.xwiki.annotation.content.AlteredContent; | |
23 | ||
24 | ||
25 | /** | |
26 | * {@link AlteredContent} implementation built as the composition of two content alterers. {@code initial} is the | |
27 | * original altered content, whose {@link AlteredContent#getContent()} was altered and the {@code altered} altered | |
28 | * content was obtained. | |
29 | * | |
30 | * @version $Id: 75b3585dffef21162d660ba4585eda42e4ea3d8b $ | |
31 | * @since 2.3M1 | |
32 | */ | |
33 | public class ComposedAlteredContent implements AlteredContent | |
34 | { | |
35 | /** | |
36 | * The original altered content. | |
37 | */ | |
38 | private AlteredContent initial; | |
39 | ||
40 | /** | |
41 | * The altered content representing the alteration of {@link #initial}'s content. | |
42 | */ | |
43 | private AlteredContent altered; | |
44 | ||
45 | /** | |
46 | * Builds a composed content alterer for the original altered content, {@code initial} and its content's alteration, | |
47 | * {@code altered}. | |
48 | * | |
49 | * @param initial the original altered content | |
50 | * @param altered the altering of the initial altered content | |
51 | */ | |
52 | 0 | public ComposedAlteredContent(AlteredContent initial, AlteredContent altered) |
53 | { | |
54 | 0 | this.initial = initial; |
55 | 0 | this.altered = altered; |
56 | } | |
57 | ||
58 | 0 | @Override |
59 | public int getInitialOffset(int i) | |
60 | { | |
61 | 0 | int tmp = altered.getInitialOffset(i); |
62 | 0 | int rez = initial.getInitialOffset(tmp); |
63 | 0 | return rez; |
64 | } | |
65 | ||
66 | 0 | @Override |
67 | public int getInitialLength() | |
68 | { | |
69 | 0 | return initial.getInitialLength(); |
70 | } | |
71 | ||
72 | 0 | @Override |
73 | public CharSequence getContent() | |
74 | { | |
75 | 0 | return altered.getContent(); |
76 | } | |
77 | ||
78 | 0 | @Override |
79 | public int getAlteredOffset(int i) | |
80 | { | |
81 | 0 | int tmp = initial.getAlteredOffset(i); |
82 | 0 | int rez = altered.getAlteredOffset(tmp); |
83 | 0 | return rez; |
84 | } | |
85 | } |