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.Map;
025    
026    import javax.naming.NamingException;
027    
028    import org.apache.directory.shared.ldap.schema.AttributeType;
029    import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
030    
031    
032    /**
033     * An AttributeType registry service interface.
034     *
035     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036     * @version $Rev: 896579 $
037     */
038    public interface AttributeTypeRegistry extends SchemaObjectRegistry<AttributeType>, Iterable<AttributeType>
039    {
040        /**
041         * Gets an oid/name to normalizer mapping used to normalize distinguished 
042         * names.
043         *
044         * @return a map of OID Strings to OidNormalizer instances
045         */
046        Map<String, OidNormalizer> getNormalizerMapping();
047    
048    
049        /**
050         * Quick lookup to see if an attribute has descendants.
051         * 
052         * @param ancestorId the name alias or OID for an attributeType
053         * @return an Iterator over the AttributeTypes which have the ancestor
054         * within their superior chain to the top
055         * @throws NamingException if the ancestor attributeType cannot be 
056         * discerned from the ancestorId supplied
057         */
058        boolean hasDescendants( String ancestorId ) throws NamingException;
059    
060    
061        /**
062         * Get's an iterator over the set of descendant attributeTypes for
063         * some ancestor's name alias or their OID.
064         * 
065         * @param ancestorId the name alias or OID for an attributeType
066         * @return an Iterator over the AttributeTypes which have the ancestor
067         * within their superior chain to the top
068         * @throws NamingException if the ancestor attributeType cannot be 
069         * discerned from the ancestorId supplied
070         */
071        Iterator<AttributeType> descendants( String ancestorId ) throws NamingException;
072    
073    
074        /**
075         * Store the AttributeType into a map associating an AttributeType to its
076         * descendants.
077         * 
078         * @param attributeType The attributeType to register
079         * @throws NamingException If something went wrong
080         */
081        void registerDescendants( AttributeType attributeType, AttributeType ancestor ) throws NamingException;
082    
083    
084        /**
085         * Remove the AttributeType from the map associating an AttributeType to its
086         * descendants.
087         * 
088         * @param attributeType The attributeType to unregister
089         * @param ancestor its ancestor 
090         * @throws NamingException If something went wrong
091         */
092        void unregisterDescendants( AttributeType attributeType, AttributeType ancestor ) throws NamingException;
093    
094    
095        /**
096         * Add a new Oid/Normalizer couple in the OidNormalizer map
097         */
098        void addMappingFor( AttributeType attributeType ) throws NamingException;
099    
100    
101        /**
102         * Remove a new Oid/Normalizer couple in the OidNormalizer map
103         */
104        void removeMappingFor( AttributeType attributeType ) throws NamingException;
105    
106    
107        /**
108         * Copy the AttributeTypeRegistry
109         */
110        AttributeTypeRegistry copy();
111    }