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 */
020package org.apache.directory.api.ldap.model.schema.registries;
021
022
023import java.util.Iterator;
024import java.util.Map;
025
026import org.apache.directory.api.ldap.model.exception.LdapException;
027import org.apache.directory.api.ldap.model.schema.AttributeType;
028import org.apache.directory.api.ldap.model.schema.normalizers.OidNormalizer;
029
030
031/**
032 * An AttributeType registry service interface.
033 *
034 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
035 */
036public interface AttributeTypeRegistry extends SchemaObjectRegistry<AttributeType>, Iterable<AttributeType>
037{
038    /**
039     * Gets an oid/name to normalizer mapping used to normalize distinguished 
040     * names.
041     *
042     * @return a map of OID Strings to OidNormalizer instances
043     */
044    Map<String, OidNormalizer> getNormalizerMapping();
045
046
047    /**
048     * Quick lookup to see if an attribute has descendants.
049     * 
050     * @param ancestorId the name alias or OID for an attributeType
051     * @return an Iterator over the AttributeTypes which have the ancestor
052     * within their superior chain to the top
053     * @throws LdapException if the ancestor attributeType cannot be 
054     * discerned from the ancestorId supplied
055     */
056    boolean hasDescendants( String ancestorId ) throws LdapException;
057
058
059    /**
060     * Quick lookup to see if an attribute has descendants.
061     * 
062     * @param ancestor the attributeType we are looking for
063     * @return an Iterator over the AttributeTypes which have the ancestor
064     * within their superior chain to the top
065     * @throws LdapException if the ancestor attributeType cannot be 
066     * discerned from the ancestorId supplied
067     */
068    boolean hasDescendants( AttributeType ancestor ) throws LdapException;
069
070
071    /**
072     * Get's an iterator over the set of descendant attributeTypes for
073     * some ancestor's name alias or their OID.
074     * 
075     * @param ancestorId the name alias or OID for an attributeType
076     * @return an Iterator over the AttributeTypes which have the ancestor
077     * within their superior chain to the top
078     * @throws LdapException if the ancestor attributeType cannot be 
079     * discerned from the ancestorId supplied
080     */
081    Iterator<AttributeType> descendants( String ancestorId ) throws LdapException;
082
083
084    /**
085     * Get's an iterator over the set of descendant attributeTypes for
086     * some ancestor's name alias or their OID.
087     * 
088     * @param ancestor the AttributeType we are looking for
089     * @return an Iterator over the AttributeTypes which have the ancestor
090     * within their superior chain to the top
091     * @throws LdapException if the ancestor attributeType cannot be 
092     * discerned from the ancestorId supplied
093     */
094    Iterator<AttributeType> descendants( AttributeType ancestor ) throws LdapException;
095
096
097    /**
098     * Store the AttributeType into a map associating an AttributeType to its
099     * descendants.
100     * 
101     * @param attributeType The attributeType to register
102     * @param ancestor The attributeType's parent
103     * @throws LdapException If something went wrong
104     */
105    void registerDescendants( AttributeType attributeType, AttributeType ancestor ) throws LdapException;
106
107
108    /**
109     * Remove the AttributeType from the map associating an AttributeType to its
110     * descendants.
111     * 
112     * @param attributeType The attributeType to unregister
113     * @param ancestor its ancestor 
114     * @throws LdapException If something went wrong
115     */
116    void unregisterDescendants( AttributeType attributeType, AttributeType ancestor ) throws LdapException;
117
118
119    /**
120     * Add a new Oid/Normalizer couple in the OidNormalizer map
121     * 
122     * @param attributeType The AttributeType to add
123     * @throws LdapException If something went wrong
124     */
125    void addMappingFor( AttributeType attributeType ) throws LdapException;
126
127
128    /**
129     * Remove a new Oid/Normalizer couple in the OidNormalizer map
130     * 
131     * @param attributeType The AttributeType to remove
132     * @throws LdapException If something went wrong
133     */
134    void removeMappingFor( AttributeType attributeType ) throws LdapException;
135
136
137    /**
138     * Copy the AttributeTypeRegistry
139     * 
140     * @return The copied AttributeTypeRegistry
141     */
142    AttributeTypeRegistry copy();
143}