1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.filter.internal; |
21 |
|
|
22 |
|
import java.lang.reflect.InvocationHandler; |
23 |
|
import java.lang.reflect.InvocationTargetException; |
24 |
|
import java.lang.reflect.Method; |
25 |
|
import java.util.ArrayList; |
26 |
|
import java.util.List; |
27 |
|
|
28 |
|
import org.xwiki.filter.FilterDescriptor; |
29 |
|
import org.xwiki.filter.FilterDescriptorManager; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
37 |
|
public class CompositeFilter implements InvocationHandler |
38 |
|
{ |
39 |
|
private FilterDescriptorManager filterManager; |
40 |
|
|
41 |
|
private List<SubFilter> filters; |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.5 |
|
43 |
|
private static class SubFilter |
44 |
|
{ |
45 |
|
public final Object filter; |
46 |
|
|
47 |
|
public final FilterDescriptor descriptor; |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
49 |
86 |
public SubFilter(Object filter, FilterDescriptor descriptor)... |
50 |
|
{ |
51 |
86 |
this.filter = filter; |
52 |
86 |
this.descriptor = descriptor; |
53 |
|
} |
54 |
|
} |
55 |
|
|
56 |
|
|
57 |
|
@param |
58 |
|
@param |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
60 |
44 |
public CompositeFilter(FilterDescriptorManager filterManager, Object... filters)... |
61 |
|
{ |
62 |
44 |
this.filterManager = filterManager; |
63 |
|
|
64 |
44 |
this.filters = new ArrayList<SubFilter>(filters.length); |
65 |
44 |
for (Object filter : filters) { |
66 |
86 |
this.filters.add(new SubFilter(filter, this.filterManager.getFilterDescriptor(filter.getClass()))); |
67 |
|
} |
68 |
|
} |
69 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
70 |
1510 |
@Override... |
71 |
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable |
72 |
|
{ |
73 |
1510 |
for (SubFilter filter : this.filters) { |
74 |
3010 |
try { |
75 |
3010 |
FilterProxy.invoke(filter.filter, filter.descriptor, method, args); |
76 |
|
} catch (InvocationTargetException e) { |
77 |
0 |
throw e.getCause(); |
78 |
|
} |
79 |
|
} |
80 |
|
|
81 |
1510 |
return null; |
82 |
|
} |
83 |
|
} |