1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.xdbm.search.evaluator;
21
22
23 import org.apache.directory.api.ldap.model.entry.Entry;
24 import org.apache.directory.api.ldap.model.exception.LdapException;
25 import org.apache.directory.api.ldap.model.filter.ScopeNode;
26 import org.apache.directory.server.core.api.partition.PartitionTxn;
27 import org.apache.directory.server.i18n.I18n;
28 import org.apache.directory.server.xdbm.IndexEntry;
29 import org.apache.directory.server.xdbm.Store;
30 import org.apache.directory.server.xdbm.search.Evaluator;
31
32
33
34
35
36
37
38 public class BaseLevelScopeEvaluator<E> implements Evaluator<ScopeNode>
39 {
40
41 private final ScopeNode node;
42
43
44 private final String baseId;
45
46
47 private final boolean dereferencing;
48
49
50 private final Store db;
51
52
53
54
55
56
57
58
59 public BaseLevelScopeEvaluator( Store db, ScopeNode node )
60 {
61 this.node = node;
62
63 this.db = db;
64 baseId = node.getBaseId();
65 dereferencing = node.getDerefAliases().isDerefInSearching() || node.getDerefAliases().isDerefAlways();
66 }
67
68
69
70
71
72
73
74
75
76
77
78 public boolean evaluate( Entry candidate ) throws LdapException
79 {
80 throw new UnsupportedOperationException( I18n.err( I18n.ERR_721 ) );
81 }
82
83
84
85
86
87 @Override
88 public boolean evaluate( PartitionTxn partitionTxn, IndexEntry<?, String> indexEntry ) throws LdapException
89 {
90 Entry entry = indexEntry.getEntry();
91
92
93 if ( null == entry )
94 {
95 entry = db.fetch( partitionTxn, indexEntry.getId() );
96
97 if ( null == entry )
98 {
99
100 return false;
101 }
102
103 indexEntry.setEntry( entry );
104 }
105
106 return true;
107 }
108
109
110 public ScopeNode getExpression()
111 {
112 return node;
113 }
114
115
116
117
118
119
120
121 public String getBaseId()
122 {
123 return baseId;
124 }
125
126
127
128
129
130
131
132 public boolean isDereferencing()
133 {
134 return dereferencing;
135 }
136
137
138
139
140
141 public String toString( String tabs )
142 {
143 StringBuilder sb = new StringBuilder();
144
145 sb.append( tabs ).append( "BaseLevelScopEvaluator : " ).append( node ).append( "\n" );
146
147 return sb.toString();
148 }
149
150
151
152
153
154 public String toString()
155 {
156 return toString( "" );
157 }
158 }