1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.wikimodel.util.tmp; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.xwiki.rendering.wikimodel.util.IListListener; |
26 |
|
import org.xwiki.rendering.wikimodel.util.TreeBuilder; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 12 |
Complexity Density: 0.6 |
|
35 |
|
public class ListBuilder2 |
36 |
|
{ |
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 6 |
Complexity Density: 0.55 |
|
37 |
|
static class CharPos implements TreeBuilder.IPos<CharPos> |
38 |
|
{ |
39 |
|
private int fPos; |
40 |
|
|
41 |
|
private char fRowChar; |
42 |
|
|
43 |
|
private char fTreeChar; |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
45 |
0 |
public CharPos(char treeChar, char rowChar, int pos)... |
46 |
|
{ |
47 |
0 |
fPos = pos; |
48 |
0 |
fTreeChar = treeChar; |
49 |
0 |
fRowChar = rowChar; |
50 |
|
} |
51 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
52 |
0 |
@Override... |
53 |
|
public boolean equals(Object obj) |
54 |
|
{ |
55 |
0 |
if (obj == this) { |
56 |
0 |
return true; |
57 |
|
} |
58 |
0 |
if (!(obj instanceof CharPos)) { |
59 |
0 |
return false; |
60 |
|
} |
61 |
0 |
CharPos pos = (CharPos) obj; |
62 |
0 |
return equalsData(pos) && pos.fPos == fPos; |
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
0 |
public boolean equalsData(CharPos pos)... |
66 |
|
{ |
67 |
0 |
return pos.fTreeChar == fTreeChar; |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0 |
public int getPos()... |
71 |
|
{ |
72 |
0 |
return fPos; |
73 |
|
} |
74 |
|
} |
75 |
|
|
76 |
|
TreeBuilder<CharPos> fBuilder = new TreeBuilder<CharPos>( |
77 |
|
new TreeBuilder.ITreeListener<CharPos>() |
78 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
0 |
public void onBeginRow(CharPos pos)... |
80 |
|
{ |
81 |
0 |
fListener.beginRow(pos.fTreeChar, pos.fRowChar); |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
0 |
public void onBeginTree(CharPos pos)... |
85 |
|
{ |
86 |
0 |
fListener.beginTree(pos.fTreeChar); |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
89 |
0 |
public void onEndRow(CharPos pos)... |
90 |
|
{ |
91 |
0 |
fListener.endRow(pos.fTreeChar, pos.fRowChar); |
92 |
|
} |
93 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
0 |
public void onEndTree(CharPos pos)... |
95 |
|
{ |
96 |
0 |
fListener.endTree(pos.fTreeChar); |
97 |
|
} |
98 |
|
}); |
99 |
|
|
100 |
|
private IListListener fListener; |
101 |
|
|
102 |
|
|
103 |
|
@param |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0 |
public ListBuilder2(IListListener listener)... |
106 |
|
{ |
107 |
0 |
fListener = listener; |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
@param |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
113 |
0 |
public void alignContext(String row)... |
114 |
|
{ |
115 |
0 |
List<CharPos> list = getCharPositions(row); |
116 |
0 |
fBuilder.align(list); |
117 |
|
} |
118 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 5 |
Complexity Density: 0.42 |
|
119 |
0 |
private List<CharPos> getCharPositions(String s)... |
120 |
|
{ |
121 |
0 |
List<CharPos> list = new ArrayList<CharPos>(); |
122 |
0 |
char[] array = s.toCharArray(); |
123 |
0 |
int pos = 0; |
124 |
0 |
for (int i = 0; i < array.length; i++) { |
125 |
0 |
char ch = array[i]; |
126 |
0 |
if (ch == '\r' || ch == '\n') { |
127 |
0 |
continue; |
128 |
|
} |
129 |
0 |
if (!Character.isSpaceChar(ch)) { |
130 |
0 |
char treeChar = getTreeType(ch); |
131 |
0 |
list.add(new CharPos(treeChar, ch, pos)); |
132 |
|
} |
133 |
0 |
pos++; |
134 |
|
} |
135 |
0 |
return list; |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
@param |
140 |
|
@return |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
0 |
protected char getTreeType(char rowType)... |
143 |
|
{ |
144 |
0 |
return rowType; |
145 |
|
} |
146 |
|
} |