1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.ldap.client.api.search;
21
22
23 import org.apache.directory.api.ldap.model.filter.FilterEncoder;
24
25
26
27
28
29
30
31 class MatchingRuleAssertionFilter extends AbstractFilter
32 {
33
34 private String attribute;
35
36
37 private String matchingRule;
38
39
40 private FilterOperator operator;
41
42
43 private boolean useDnAttributes = false;
44
45
46 private String value;
47
48
49
50
51
52
53
54
55
56 MatchingRuleAssertionFilter( String attribute, String value,
57 FilterOperator operator )
58 {
59 this.attribute = attribute;
60 this.value = value;
61 this.operator = operator;
62 }
63
64
65
66
67
68
69
70
71 public static MatchingRuleAssertionFilter extensible( String value )
72 {
73 return new MatchingRuleAssertionFilter( null, value,
74 FilterOperator.EXTENSIBLE_EQUAL );
75 }
76
77
78
79
80
81
82
83
84
85 public static MatchingRuleAssertionFilter extensible( String attribute, String value )
86 {
87 return new MatchingRuleAssertionFilter( attribute, value,
88 FilterOperator.EXTENSIBLE_EQUAL );
89 }
90
91
92
93
94
95
96
97
98 public MatchingRuleAssertionFilter setMatchingRule( String matchingRule )
99 {
100 this.matchingRule = matchingRule;
101 return this;
102 }
103
104
105
106
107
108
109
110 public MatchingRuleAssertionFilter useDnAttributes()
111 {
112 this.useDnAttributes = true;
113 return this;
114 }
115
116
117
118
119
120 @Override
121 public StringBuilder build( StringBuilder builder )
122 {
123 builder.append( "(" );
124 if ( attribute != null )
125 {
126 builder.append( attribute );
127 }
128 if ( useDnAttributes )
129 {
130 builder.append( ":dn" );
131 }
132 if ( matchingRule != null && !matchingRule.isEmpty() )
133 {
134 builder.append( ":" ).append( matchingRule );
135 }
136 return builder.append( operator.operator() )
137 .append( FilterEncoder.encodeFilterValue( value ) ).append( ")" );
138 }
139 }