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.CachingNormalizer;
25  import org.apache.ldap.common.schema.ComparableComparator;
26  import org.apache.ldap.common.schema.DeepTrimNormalizer;
27  import org.apache.ldap.common.schema.DeepTrimToLowerNormalizer;
28  import org.apache.ldap.common.schema.DnComparator;
29  import org.apache.ldap.common.schema.NormalizingComparator;
30  import org.apache.ldap.server.schema.ConcreteNameComponentNormalizer;
31  
32  
33  /***
34   * Document this class.
35   *
36   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
37   * @version $Rev: 264732 $
38   */
39  public class SystemComparatorProducer extends AbstractBootstrapProducer
40  {
41      public SystemComparatorProducer()
42      {
43          super( ProducerTypeEnum.COMPARATOR_PRODUCER );
44      }
45  
46  
47      public void produce( BootstrapRegistries registries, ProducerCallback cb )
48              throws NamingException
49      {
50          Comparator comparator;
51  
52          /*
53           * Straight out of RFC 2252: Section 8
54           * =======================================
55          ( 2.5.13.0 NAME 'objectIdentifierMatch'
56            SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )
57           */
58           comparator = new ComparableComparator();
59           cb.schemaObjectProduced( this, "2.5.13.0", comparator );
60  
61          /*
62          ( 2.5.13.1 NAME 'distinguishedNameMatch'
63            SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
64            */
65           comparator = new DnComparator( new ConcreteNameComponentNormalizer(
66                   registries.getAttributeTypeRegistry() ) );
67           cb.schemaObjectProduced( this, "2.5.13.1", comparator );
68  
69           /*
70          ( 2.5.13.2 NAME 'caseIgnoreMatch'
71            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
72            */
73           comparator = new NormalizingComparator(
74                   new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
75                   new ComparableComparator() );
76           cb.schemaObjectProduced( this, "2.5.13.2", comparator );
77  
78           /*
79          ( 2.5.13.3 NAME 'caseIgnoreOrderingMatch'
80            SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
81            */
82           comparator = new NormalizingComparator(
83                   new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
84                   new ComparableComparator() );
85           cb.schemaObjectProduced( this, "2.5.13.3", comparator );
86  
87           /*
88          ( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch'
89           SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
90           */
91           comparator = new NormalizingComparator(
92                  new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
93                  new ComparableComparator() );
94           cb.schemaObjectProduced( this, "2.5.13.4", comparator );
95  
96          /*
97           ( 2.5.13.6 NAME 'caseExactOrderingMatch'
98             SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
99           */
100          comparator = new ComparableComparator();
101          cb.schemaObjectProduced( this, "2.5.13.6", comparator );
102 
103         /*
104         ( 2.5.13.8 NAME 'numericStringMatch'
105           SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )
106           */
107          comparator = new ComparableComparator();
108          cb.schemaObjectProduced( this, "2.5.13.8", comparator );
109 
110          /*
111         ( 2.5.13.10 NAME 'numericStringSubstringsMatch'
112           SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
113           */
114          comparator = new ComparableComparator();
115          cb.schemaObjectProduced( this, "2.5.13.10", comparator );
116 
117          /*
118         ( 2.5.13.11 NAME 'caseIgnoreListMatch'
119           SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )
120           */
121          comparator = new NormalizingComparator(
122                  new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
123                  new ComparableComparator() );
124          cb.schemaObjectProduced( this, "2.5.13.11", comparator );
125 
126         /*
127        ( 2.5.13.14 NAME 'integerMatch'
128          SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
129          */
130         comparator = new ComparableComparator();
131         cb.schemaObjectProduced( this, "2.5.13.14", comparator );
132 
133         /*
134        ( 2.5.13.14 NAME 'integerOrderingMatch'
135          SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
136          */
137         comparator = new ComparableComparator();
138         cb.schemaObjectProduced( this, "2.5.13.15", comparator );
139 
140         /*
141        ( 2.5.13.16 NAME 'bitStringMatch'
142          SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )
143          */
144         comparator = new ComparableComparator();
145         cb.schemaObjectProduced( this, "2.5.13.16", comparator );
146 
147         /*
148        ( 2.5.13.17 NAME 'octetStringMatch'
149          SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
150          */
151         comparator = new ComparableComparator();
152         cb.schemaObjectProduced( this, "2.5.13.17", comparator );
153 
154         /*
155         ( 2.5.13.18 NAME 'octetStringOrderingMatch'
156           SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
157           */
158          comparator = new ComparableComparator();
159          cb.schemaObjectProduced( this, "2.5.13.18", comparator );
160 
161          /*
162         ( 2.5.13.20 NAME 'telephoneNumberMatch'
163           SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )
164           */
165          comparator = new ComparableComparator();
166          cb.schemaObjectProduced( this, "2.5.13.20", comparator );
167 
168          /*
169         ( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch'
170           SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )
171           */
172          comparator = new ComparableComparator();
173          cb.schemaObjectProduced( this, "2.5.13.21", comparator );
174 
175          /*
176         ( 2.5.13.22 NAME 'presentationAddressMatch'
177           SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )
178           */
179          comparator = new ComparableComparator();
180          cb.schemaObjectProduced( this, "2.5.13.22", comparator );
181 
182          /*
183         ( 2.5.13.23 NAME 'uniqueMemberMatch'
184           SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )
185           */
186          comparator = new NormalizingComparator(
187                  new CachingNormalizer( new DeepTrimNormalizer() ),
188                  new ComparableComparator() );
189          cb.schemaObjectProduced( this, "2.5.13.23", comparator );
190 
191          /*
192         ( 2.5.13.24 NAME 'protocolInformationMatch'
193           SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )
194           */
195          comparator = new ComparableComparator();
196          cb.schemaObjectProduced( this, "2.5.13.24", comparator );
197 
198          /*
199         ( 2.5.13.27 NAME 'generalizedTimeMatch'
200           SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
201           */
202          comparator = new ComparableComparator();
203          cb.schemaObjectProduced( this, "2.5.13.27", comparator );
204 
205          /*
206         ( 2.5.13.28 NAME 'generalizedTimeOrderingMatch'
207           SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )
208           */
209          comparator = new ComparableComparator();
210          cb.schemaObjectProduced( this, "2.5.13.28", comparator );
211 
212          /*
213         ( 2.5.13.29 NAME 'integerFirstComponentMatch'
214           SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )
215           */
216          comparator = new ComparableComparator();
217          cb.schemaObjectProduced( this, "2.5.13.29", comparator );
218 
219          /*
220         ( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch'
221           SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )
222           */
223          comparator = new ComparableComparator();
224          cb.schemaObjectProduced( this, "2.5.13.30", comparator );
225 
226          /*
227         ( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match'
228           SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
229           */
230          comparator = new NormalizingComparator(
231                  new CachingNormalizer( new DeepTrimNormalizer() ),
232                  new ComparableComparator() );
233          cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.1", comparator );
234 
235          /*
236         ( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match'
237           SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
238           */
239          comparator = new NormalizingComparator(
240                  new CachingNormalizer( new DeepTrimToLowerNormalizer() ),
241                  new ComparableComparator() );
242          cb.schemaObjectProduced( this, "1.3.6.1.4.1.1466.109.114.2", comparator );
243 
244         /*
245          * MatchingRules from section 2 of http://www.faqs.org/rfcs/rfc3698.html
246          * for Additional MatchingRules
247 
248          ( 2.5.13.13 NAME 'booleanMatch'
249            SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )
250 
251          */
252 
253         comparator = new ComparableComparator();
254         cb.schemaObjectProduced( this, "2.5.13.13", comparator );
255 
256     }
257 }