View Javadoc

1   /*
2    *   Copyright 2004 The Apache Software Foundation
3    *
4    *   Licensed under the Apache License, Version 2.0 (the "License");
5    *   you may not use this file except in compliance with the License.
6    *   You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *   Unless required by applicable law or agreed to in writing, software
11   *   distributed under the License is distributed on an "AS IS" BASIS,
12   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *   See the License for the specific language governing permissions and
14   *   limitations under the License.
15   *
16   */
17  package org.apache.ldap.server.schema.bootstrap;
18  
19  
20  import java.util.Comparator;
21  
22  import javax.naming.NamingException;
23  
24  import org.apache.ldap.common.schema.*;
25  import org.apache.ldap.server.schema.ConcreteNameComponentNormalizer;
26  
27  
28  /***
29   * Document this class.
30   *
31   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   * @version $Rev: 289953 $
33   */
34  public class SystemComparatorProducer extends AbstractBootstrapProducer
35  {
36      public SystemComparatorProducer()
37      {
38          super( ProducerTypeEnum.COMPARATOR_PRODUCER );
39      }
40  
41  
42      public void produce( BootstrapRegistries registries, ProducerCallback cb )
43              throws NamingException
44      {
45          Comparator comparator;
46  
47          /*
48           * Straight out of RFC 2252: Section 8
49           * =======================================
50          ( 2.5.13.0 NAME 'objectIdentifierMatch'
51            SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )
52           */
53           comparator = new ObjectIdentifierComparator();
54           cb.schemaObjectProduced( this, "2.5.13.0", comparator );
55  
56          /*
57          ( 2.5.13.1 NAME 'distinguishedNameMatch'
58            SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
59            */
60           comparator = new DnComparator( new ConcreteNameComponentNormalizer(
61                   registries.getAttributeTypeRegistry() ) );
62           cb.schemaObjectProduced( this, "2.5.13.1", comparator );
63  
64           /*
65          ( 2.5.13.2 NAME 'caseIgnoreMatch'
66            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
67            */
68           comparator = new NormalizingComparator(
69                   new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
70                   new ComparableComparator() );
71           cb.schemaObjectProduced( this, "2.5.13.2", comparator );
72  
73           /*
74          ( 2.5.13.3 NAME 'caseIgnoreOrderingMatch'
75            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
76            */
77           comparator = new NormalizingComparator(
78                   new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
79                   new ComparableComparator() );
80           cb.schemaObjectProduced( this, "2.5.13.3", comparator );
81  
82           /*
83          ( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch'
84           SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
85           */
86           comparator = new NormalizingComparator(
87                  new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
88                  new ComparableComparator() );
89           cb.schemaObjectProduced( this, "2.5.13.4", comparator );
90  
91          /*
92           ( 2.5.13.6 NAME 'caseExactOrderingMatch'
93             SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
94           */
95           comparator = new ComparableComparator();
96           cb.schemaObjectProduced( this, "2.5.13.6", comparator );
97  
98          /*
99          ( 2.5.13.8 NAME 'numericStringMatch'
100           SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )
101           */
102          comparator = new ComparableComparator();
103          cb.schemaObjectProduced( this, "2.5.13.8", comparator );
104 
105          /*
106         ( 2.5.13.10 NAME 'numericStringSubstringsMatch'
107           SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
108           */
109          comparator = new ComparableComparator();
110          cb.schemaObjectProduced( this, "2.5.13.10", comparator );
111 
112          /*
113         ( 2.5.13.11 NAME 'caseIgnoreListMatch'
114           SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
115           */
116          comparator = new NormalizingComparator(
117                  new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
118                  new ComparableComparator() );
119          cb.schemaObjectProduced( this, "2.5.13.11", comparator );
120 
121         /*
122        ( 2.5.13.14 NAME 'integerMatch'
123          SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
124          */
125         comparator = new ComparableComparator();
126         cb.schemaObjectProduced( this, "2.5.13.14", comparator );
127 
128         /*
129        ( 2.5.13.14 NAME 'integerOrderingMatch'
130          SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
131          */
132         comparator = new ComparableComparator();
133         cb.schemaObjectProduced( this, "2.5.13.15", comparator );
134 
135         /*
136        ( 2.5.13.16 NAME 'bitStringMatch'
137          SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )
138          */
139         comparator = new ComparableComparator();
140         cb.schemaObjectProduced( this, "2.5.13.16", comparator );
141 
142         /*
143        ( 2.5.13.17 NAME 'octetStringMatch'
144          SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
145          */
146         comparator = new ComparableComparator();
147         cb.schemaObjectProduced( this, "2.5.13.17", comparator );
148 
149         /*
150         ( 2.5.13.18 NAME 'octetStringOrderingMatch'
151           SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
152           */
153          comparator = new ComparableComparator();
154          cb.schemaObjectProduced( this, "2.5.13.18", comparator );
155 
156          /*
157         ( 2.5.13.20 NAME 'telephoneNumberMatch'
158           SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )
159           */
160          comparator = new ComparableComparator();
161          cb.schemaObjectProduced( this, "2.5.13.20", comparator );
162 
163          /*
164         ( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch'
165           SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
166           */
167          comparator = new ComparableComparator();
168          cb.schemaObjectProduced( this, "2.5.13.21", comparator );
169 
170          /*
171         ( 2.5.13.22 NAME 'presentationAddressMatch'
172           SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )
173           */
174          comparator = new ComparableComparator();
175          cb.schemaObjectProduced( this, "2.5.13.22", comparator );
176 
177          /*
178         ( 2.5.13.23 NAME 'uniqueMemberMatch'
179           SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )
180           */
181          comparator = new NormalizingComparator(
182                  new CachingNormalizer( new DeepTrimNormalizer() ),
183                  new ComparableComparator() );
184          cb.schemaObjectProduced( this, "2.5.13.23", comparator );
185 
186          /*
187         ( 2.5.13.24 NAME 'protocolInformationMatch'
188           SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )
189           */
190          comparator = new ComparableComparator();
191          cb.schemaObjectProduced( this, "2.5.13.24", comparator );
192 
193          /*
194         ( 2.5.13.27 NAME 'generalizedTimeMatch'
195           SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
196           */
197          comparator = new ComparableComparator();
198          cb.schemaObjectProduced( this, "2.5.13.27", comparator );
199 
200          /*
201         ( 2.5.13.28 NAME 'generalizedTimeOrderingMatch'
202           SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
203           */
204          comparator = new ComparableComparator();
205          cb.schemaObjectProduced( this, "2.5.13.28", comparator );
206 
207          /*
208         ( 2.5.13.29 NAME 'integerFirstComponentMatch'
209           SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
210           */
211          comparator = new ComparableComparator();
212          cb.schemaObjectProduced( this, "2.5.13.29", comparator );
213 
214          /*
215         ( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch'
216           SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )
217           */
218          comparator = new ComparableComparator();
219          cb.schemaObjectProduced( this, "2.5.13.30", comparator );
220 
221         /*
222          * Straight out of RFC 3698: Section 2.6
223          * http://www.faqs.org/rfcs/rfc3698.html
224          * =======================================
225          * ( 2.5.13.31 NAME 'directoryStringFirstComponentMatch'
226          *   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
227          */
228         comparator = new ComparableComparator();
229         cb.schemaObjectProduced( this, "2.5.13.31", comparator );
230 
231          /*
232         ( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match'
233           SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
234           */
235          comparator = new NormalizingComparator(
236                  new CachingNormalizer( new DeepTrimNormalizer() ),
237                  new ComparableComparator() );
238          cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.1", comparator );
239 
240          /*
241         ( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match'
242           SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
243           */
244          comparator = new NormalizingComparator(
245                  new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
246                  new ComparableComparator() );
247          cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.2", comparator );
248 
249         /*
250          * MatchingRules from section 2 of http://www.faqs.org/rfcs/rfc3698.html
251          * for Additional MatchingRules
252 
253          ( 2.5.13.13 NAME 'booleanMatch'
254            SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )
255 
256          */
257 
258         comparator = new ComparableComparator();
259         cb.schemaObjectProduced( this, "2.5.13.13", comparator );
260 
261     }
262 }