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.jcr.iterator;
35
36 import info.magnolia.jcr.decoration.ContentDecorator;
37 import info.magnolia.jcr.predicate.AbstractPredicate;
38 import info.magnolia.jcr.wrapper.PropertyWrapperFactory;
39
40 import javax.jcr.Property;
41 import javax.jcr.PropertyIterator;
42
43
44
45
46 public class FilteringPropertyIterator extends FilteringRangeIterator<Property> implements PropertyIterator {
47
48
49
50
51 @Deprecated
52 private PropertyWrapperFactory wrapperFactory;
53 private AbstractPredicate<Property> predicate;
54 private ContentDecorator decorator;
55
56 public FilteringPropertyIterator(PropertyIterator propertyIterator, AbstractPredicate<Property> predicate) {
57 this(propertyIterator, predicate, (ContentDecorator) null);
58 }
59
60 public FilteringPropertyIterator(PropertyIterator propertyIterator, AbstractPredicate<Property> predicate, ContentDecorator decorator) {
61 super(propertyIterator);
62 this.predicate = predicate;
63 this.decorator = decorator;
64 }
65
66
67
68
69 @Deprecated
70 public FilteringPropertyIterator(PropertyIterator propertyIterator, AbstractPredicate<Property> predicate, PropertyWrapperFactory wrapperFactory) {
71 super(propertyIterator);
72 this.wrapperFactory = wrapperFactory;
73 this.predicate = predicate;
74 }
75
76 @Override
77 public Property next() {
78 return wrapProperty(super.next());
79 }
80
81 @Override
82 public Property nextProperty() {
83 return wrapProperty(super.next());
84 }
85
86 protected Property wrapProperty(Property property) {
87 if (decorator != null) {
88 return decorator.wrapProperty(property);
89 } else if (wrapperFactory != null) {
90 return wrapProperty(property);
91 } else {
92 return property;
93 }
94 }
95
96 @Override
97 protected boolean evaluate(Property property) {
98 return predicate == null || predicate.evaluate(property);
99 }
100 }