1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.rest.delivery.jcr.filter; |
35 |
|
|
36 |
|
import info.magnolia.jcr.iterator.FilteringRangeIterator; |
37 |
|
import info.magnolia.jcr.wrapper.ChildFilteringContentDecorator; |
38 |
|
|
39 |
|
import javax.jcr.Node; |
40 |
|
import javax.jcr.NodeIterator; |
41 |
|
import javax.jcr.RepositoryException; |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
|
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 6 |
Complexity Density: 0.67 |
|
46 |
|
public class DepthFilteringDecoratorNodeIterator extends FilteringRangeIterator<Node> implements NodeIterator { |
47 |
|
|
48 |
|
private final int depth; |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
50 |
2 |
public DepthFilteringDecoratorNodeIterator(NodeIterator nodeIterator, int depth) {... |
51 |
2 |
super(nodeIterator); |
52 |
2 |
this.depth = depth; |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
6 |
@Override... |
56 |
|
public Node next() { |
57 |
6 |
return wrapNode(super.next()); |
58 |
|
} |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
0 |
@Override... |
61 |
|
public Node nextNode() { |
62 |
0 |
return wrapNode(super.next()); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
6 |
@Override... |
66 |
|
protected boolean evaluate(Node node) { |
67 |
6 |
return true; |
68 |
|
} |
69 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
70 |
6 |
protected Node wrapNode(Node node) {... |
71 |
6 |
try { |
72 |
6 |
ChildFilteringContentDecorator depthDecorator = new ChildFilteringContentDecorator(new DepthFilteringPredicate(node.getDepth(), node.getDepth() + depth), true); |
73 |
6 |
return depthDecorator.wrapNode(node); |
74 |
|
} catch (RepositoryException e) { |
75 |
|
|
76 |
|
} |
77 |
|
|
78 |
0 |
return node; |
79 |
|
} |
80 |
|
} |