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.shared.ldap.schema.registries;
021    
022    
023    import java.util.Iterator;
024    import java.util.List;
025    
026    import javax.naming.NamingException;
027    
028    import org.apache.directory.shared.ldap.schema.ObjectClass;
029    
030    
031    /**
032     * ObjectClass registry service interface.
033     *
034     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035     * @version $Rev: 896579 $
036     */
037    public interface ObjectClassRegistry extends SchemaObjectRegistry<ObjectClass>,
038        Iterable<ObjectClass>
039    {
040        /**
041         * Quick lookup to see if an objectClass has descendants.
042         * 
043         * @param ancestorId the name alias or OID for an ObjectClass
044         * @return an Iterator over the ObjectClasses which have the ancestor
045         * within their superior chain to the top
046         * @throws NamingException if the ancestor ObjectClass cannot be 
047         * discerned from the ancestorId supplied
048         */
049        boolean hasDescendants( String ancestorId ) throws NamingException;
050        
051        
052        /**
053         * Get's an iterator over the set of descendant ObjectClasses for
054         * some ancestor's name alias or their OID.
055         * 
056         * @param ancestorId the name alias or OID for an ObjectClass
057         * @return an Iterator over the ObjectClasses which have the ancestor
058         * within their superior chain to the top
059         * @throws NamingException if the ancestor ObjectClass cannot be 
060         * discerned from the ancestorId supplied
061         */
062        Iterator<ObjectClass> descendants( String ancestorId ) throws NamingException;
063    
064        
065        /**
066         * Store the ObjectClass into a map associating an ObjectClass to its
067         * descendants.
068         * 
069         * @param attributeType The ObjectClass to register
070         * @throws NamingException If something went wrong
071         */
072        void registerDescendants( ObjectClass objectClass, List<ObjectClass> ancestors ) 
073            throws NamingException;
074        
075        
076        /**
077         * Remove the ObjectClass from the map associating an ObjectClass to its
078         * descendants.
079         * 
080         * @param attributeType The ObjectClass to unregister
081         * @param ancestor its ancestor 
082         * @throws NamingException If something went wrong
083         */
084        void unregisterDescendants( ObjectClass attributeType, List<ObjectClass> ancestors ) 
085            throws NamingException;
086        
087        
088        /**
089         * Registers a new ObjectClass with this registry.
090         *
091         * @param objectClass the ObjectClass to register
092         * @throws NamingException if the ObjectClass is already registered or
093         * the registration operation is not supported
094         */
095        void register( ObjectClass objectClass ) throws NamingException;
096        
097        
098        /**
099         * Removes the ObjectClass registered with this registry.
100         * 
101         * @param numericOid the numeric identifier
102         * @throws NamingException if the numeric identifier is invalid
103         */
104        ObjectClass unregister( String numericOid ) throws NamingException;
105        
106        
107        /**
108         * Copy the ObjectClassRegistry
109         */
110        ObjectClassRegistry copy();
111    }