001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    package org.apache.directory.server.schema.bootstrap;
021    
022    
023    import java.util.Comparator;
024    
025    import javax.naming.NamingException;
026    
027    import jdbm.helper.StringComparator;
028    
029    import org.apache.directory.server.schema.bootstrap.ProducerTypeEnum;
030    import org.apache.directory.server.schema.registries.Registries;
031    import org.apache.directory.shared.ldap.constants.SchemaConstants;
032    import org.apache.directory.shared.ldap.schema.comparators.CsnComparator;
033    import org.apache.directory.shared.ldap.schema.comparators.ComparableComparator;
034    import org.apache.directory.shared.ldap.schema.comparators.CsnSidComparator;
035    import org.apache.directory.shared.ldap.schema.comparators.UUIDComparator;
036    import org.apache.directory.shared.ldap.util.LongComparator;
037    
038    
039    /**
040     * A producer of Comparator objects for the eve schema.
041     * Probably modified by hand from generated code
042     *
043     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
044     * @version $Rev: 803313 $
045     */
046    public class ApacheComparatorProducer extends AbstractBootstrapProducer
047    {
048        public ApacheComparatorProducer()
049        {
050            super( ProducerTypeEnum.COMPARATOR_PRODUCER );
051        }
052    
053    
054        // ------------------------------------------------------------------------
055        // BootstrapProducer Methods
056        // We need comparator for :
057        // - exactDnAsStringMatch  1.3.6.1.4.1.18060.0.4.1.1.1  (ComparableComparator)
058        // - bigIntegerMatch       1.3.6.1.4.1.18060.0.4.1.1.2  (LongComparator)
059        // - jdbmStringMatch       1.3.6.1.4.1.18060.0.4.1.1.3  (StringComparator)
060        // - uuidMatch             1.3.6.1.1.16.2  (UUIDComparator)
061        // - uuidOrderingMatch     1.3.6.1.1.16.3  (UUIDComparator)
062        // - CSNMatch              1.3.6.1.4.1.4203.666.11.2.2  (CsnComparator)
063        // - CSNOrderingMatch      1.3.6.1.4.1.4203.666.11.2.3  (CsnComparator)
064        // - CSNSIDMatch           1.3.6.1.4.1.4203.666.11.2.5  (CsnSidComparator)
065        // ------------------------------------------------------------------------
066    
067        /**
068         * @see org.apache.directory.server.schema.bootstrap.BootstrapProducer#produce(org.apache.directory.server.schema.registries.DefaultRegistries, ProducerCallback)
069         */
070        public void produce( Registries registries, ProducerCallback cb ) throws NamingException
071        {
072            Comparator<?> comparator;
073    
074            // For exactDnAsStringMatch -> 1.3.6.1.4.1.18060.0.4.1.1.1
075            comparator = new ComparableComparator();
076            cb.schemaObjectProduced( this, "1.3.6.1.4.1.18060.0.4.1.1.1", comparator );
077    
078            // For bigIntegerMatch -> 1.3.6.1.4.1.18060.0.4.1.1.2
079            comparator = new LongComparator();
080            cb.schemaObjectProduced( this, "1.3.6.1.4.1.18060.0.4.1.1.2", comparator );
081    
082            // For jdbmStringMatch -> 1.3.6.1.4.1.18060.0.4.1.1.3
083            comparator = new StringComparator();
084            cb.schemaObjectProduced( this, "1.3.6.1.4.1.18060.0.4.1.1.3", comparator );
085    
086            // For uuidMatch
087            comparator = new UUIDComparator();
088            cb.schemaObjectProduced( this, SchemaConstants.UUID_MATCH_MR_OID, comparator );
089    
090            // For uuidOrderingMatch
091            comparator = new UUIDComparator();
092            cb.schemaObjectProduced( this, SchemaConstants.UUID_ORDERING_MATCH_MR_OID, comparator );
093            
094            // For CSNMatch
095            comparator = new CsnComparator();
096            cb.schemaObjectProduced( this, SchemaConstants.CSN_MATCH_MR_OID, comparator );
097            
098            // For CSNOrderingMatch
099            comparator = new CsnComparator();
100            cb.schemaObjectProduced( this, SchemaConstants.CSN_ORDERING_MATCH_MR_OID, comparator );
101            
102            // For CSNSIDMatch
103            comparator = new CsnSidComparator();
104            cb.schemaObjectProduced( this, SchemaConstants.CSN_SID_MATCH_MR_OID, comparator );
105        }
106    }