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.registries;
021    
022    
023    import java.util.Comparator;
024    import java.util.Iterator;
025    
026    import javax.naming.NamingException;
027    
028    import org.apache.directory.shared.ldap.schema.parsers.ComparatorDescription;
029    
030    
031    /**
032     * Comparator registry component's service interface.
033     *
034     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035     * @version $Rev: 780471 $
036     */
037    public interface ComparatorRegistry extends Iterable<String>
038    {
039        /**
040         * Gets the name of the schema this schema object is associated with.
041         *
042         * @param oid the object identifier
043         * @return the schema name
044         * @throws NamingException if the schema object does not exist 
045         */
046        String getSchemaName( String oid ) throws NamingException;
047    
048    
049        /**
050         * Registers a Comparator with this registry.
051         * 
052         * @param description the comparatorDescription for the comparator to register
053         * @param comparator the Comparator to register
054         * @throws NamingException if the Comparator is already registered or the 
055         *      registration operation is not supported
056         */
057        void register( ComparatorDescription description, Comparator<?> comparator ) throws NamingException;
058    
059    
060        /**
061         * Looks up a Comparator by its unique Object Identifier.
062         * 
063         * @param oid the object identifier
064         * @return the Comparator for the oid
065         * @throws NamingException if there is a backing store failure or the 
066         *      Comparator does not exist.
067         */
068        Comparator<?> lookup( String oid ) throws NamingException;
069    
070    
071        /**
072         * Checks to see if a Comparator exists.  Backing store failures simply 
073         * return false.
074         * 
075         * @param oid the object identifier
076         * @return true if a Comparator definition exists for the oid, false 
077         *      otherwise
078         */
079        boolean hasComparator( String oid );
080    
081    
082        /**
083         * Iterates over the numeric OID strings of this registry.
084         * 
085         * @return Iterator of numeric OID strings 
086         */
087        Iterator<String> iterator();
088    
089        
090        /**
091         * Iterates over the numeric OID strings of this registry.
092         * 
093         * @return Iterator of numeric OID strings 
094         */
095        Iterator<ComparatorDescription> comparatorDescriptionIterator();
096    
097        
098        /**
099         * Removes a registered comparator from this registry.
100         * 
101         * @param oid the numeric oid of the comparator to remove.
102         * @throws NamingException if the oid is not a numeric id
103         */
104        void unregister( String oid ) throws NamingException;
105        
106        
107        /**
108         * Unregisters comparators from this registry associated with a schema.
109         *
110         * @param schemaName the name of the schema whose comparators are removed 
111         * from this registry
112         */
113        void unregisterSchemaElements( String schemaName );
114        
115        
116        /**
117         * Renames the schemaName associated with entities within this 
118         * registry to a new schema name.
119         * 
120         * @param originalSchemaName the original schema name
121         * @param newSchemaName the new name to give to the schema
122         */
123        void renameSchema( String originalSchemaName, String newSchemaName );
124    }