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 org.apache.directory.shared.ldap.schema.AttributeType;
024    import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
025    
026    import javax.naming.NamingException;
027    import java.util.Iterator;
028    import java.util.Map;
029    
030    
031    /**
032     * An AttributeType registry service interface.
033     *
034     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035     * @version $Rev: 780471 $
036     */
037    public interface AttributeTypeRegistry extends SchemaObjectRegistry, Iterable<AttributeType>
038    {
039        /**
040         * Registers a new AttributeType with this registry.
041         *
042         * @param attributeType the AttributeType to register
043         * @throws NamingException if the AttributeType is already registered or
044         * the registration operation is not supported
045         */
046        void register( AttributeType attributeType ) throws NamingException;
047    
048    
049        /**
050         * Looks up an AttributeType by its unique Object Identifier or by its
051         * unique name.
052         * 
053         * @param id the object identifier or name of the AttributeType
054         * @return the AttributeType instance for the oid
055         * @throws NamingException if the AttributeType does not exist
056         */
057        AttributeType lookup( String id ) throws NamingException;
058    
059    
060        /**
061         * Checks to see if an AttributeType exists.
062         * 
063         * @param id the object identifier or name of the AttributeType
064         * @return true if an AttributeType definition exists for the oid, false
065         * otherwise
066         */
067        boolean hasAttributeType( String id );
068    
069    
070        /**
071         * Gets an Iterator over the AttributeTypes within this registry.
072         *
073         * @return an iterator over all AttributeTypes in registry
074         */
075        Iterator<AttributeType> iterator();
076        
077        
078        /**
079         * Gets an oid/name to normalizer mapping used to normalize distinguished 
080         * names.
081         *
082         * @return a map of OID Strings to OidNormalizer instances
083         * @throws NamingException if for some reason this information cannot be returned
084         */
085        Map<String, OidNormalizer> getNormalizerMapping() throws NamingException; 
086        
087        /**
088         * Quick lookup to see if an attribute has descendants.
089         * 
090         * @param ancestorId the name alias or OID for an attributeType
091         * @return an Iterator over the AttributeTypes which have the ancestor
092         * within their superior chain to the top
093         * @throws NamingException if the ancestor attributeType cannot be 
094         * discerned from the ancestorId supplied
095         */
096        boolean hasDescendants( String ancestorId ) throws NamingException;
097        
098        /**
099         * Get's an iterator over the set of descendant attributeTypes for
100         * some ancestor's name alias or their OID.
101         * 
102         * @param ancestorId the name alias or OID for an attributeType
103         * @return an Iterator over the AttributeTypes which have the ancestor
104         * within their superior chain to the top
105         * @throws NamingException if the ancestor attributeType cannot be 
106         * discerned from the ancestorId supplied
107         */
108        Iterator<AttributeType> descendants( String ancestorId ) throws NamingException;
109    }