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.schema.loader;
021
022
023import org.apache.directory.api.ldap.model.entry.Entry;
024import org.apache.directory.api.ldap.model.exception.LdapException;
025import org.apache.directory.api.ldap.model.schema.AttributeType;
026import org.apache.directory.api.ldap.model.schema.LdapComparator;
027import org.apache.directory.api.ldap.model.schema.LdapSyntax;
028import org.apache.directory.api.ldap.model.schema.MatchingRule;
029import org.apache.directory.api.ldap.model.schema.Normalizer;
030import org.apache.directory.api.ldap.model.schema.ObjectClass;
031import org.apache.directory.api.ldap.model.schema.SchemaManager;
032import org.apache.directory.api.ldap.model.schema.SyntaxChecker;
033import org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription;
034import org.apache.directory.api.ldap.model.schema.parsers.NormalizerDescription;
035import org.apache.directory.api.ldap.model.schema.parsers.SyntaxCheckerDescription;
036import org.apache.directory.api.ldap.model.schema.registries.Registries;
037import org.apache.directory.api.ldap.model.schema.registries.Schema;
038
039
040/**
041 * An interface to be implemented by classes needed to create Schema elements. The factory
042 * will creates schema elements based on an Entry.
043 * 
044 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
045 */
046public interface EntityFactory
047{
048    /**
049     * Return an instance of the Schema associated to the entry
050     *
051     * @param entry The Schema entry
052     * @return An instance of a Schema
053     * @throws LdapException If the instance can't be created
054     */
055    Schema getSchema( Entry entry ) throws LdapException;
056
057
058    /**
059     * Construct an AttributeType from an entry representing an AttributeType.
060     *
061     * @param schemaManager The Schema Manager
062     * @param entry The entry containing all the informations to build an AttributeType
063     * @param targetRegistries The registries containing all the enabled SchemaObjects
064     * @param schemaName The schema this SchemaObject will be part of
065     * @return An AttributeType SchemaObject
066     * @throws LdapException If the AttributeType is invalid
067     */
068    AttributeType getAttributeType( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
069        String schemaName ) throws LdapException;
070
071
072    /**
073     * Construct a LdapComparator from a description of a comparator.
074     *
075     * @param schemaManager The Schema Manager
076     * @param comparatorDescription The LdapComparator description object 
077     * @param targetRegistries The registries containing all the enabled SchemaObjects
078     * @param schemaName The schema this SchemaObject will be part of
079     * @return A new instance of a LdapComparator
080     * @throws LdapException If the creation has failed
081     */
082    LdapComparator<?> getLdapComparator( SchemaManager schemaManager,
083        LdapComparatorDescription comparatorDescription,
084        Registries targetRegistries, String schemaName ) throws LdapException;
085
086
087    /**
088     * Retrieve and load a Comparator class from the DIT.
089     * 
090     * @param schemaManager The Schema Manager
091     * @param entry The entry containing all the informations to build a LdapComparator
092     * @param targetRegistries The registries containing all the enabled SchemaObjects
093     * @param schemaName The schema this SchemaObject will be part of
094     * @return the loaded Comparator
095     * @throws LdapException if anything fails during loading
096     */
097    LdapComparator<?> getLdapComparator( SchemaManager schemaManager, Entry entry,
098        Registries targetRegistries, String schemaName ) throws LdapException;
099
100
101    /**
102     * Construct an MatchingRule from an entry get from the Dit
103     *
104     * @param schemaManager The Schema Manager
105     * @param entry The entry containing all the informations to build a MatchingRule
106     * @param targetRegistries The registries containing all the enabled SchemaObjects
107     * @param schemaName The schema this SchemaObject will be part of
108     * @return A MatchingRule SchemaObject
109     * @throws LdapException If the MatchingRule is invalid
110     */
111    MatchingRule getMatchingRule( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
112        String schemaName ) throws LdapException;
113
114
115    /**
116     * Create a new instance of a Normalizer 
117     *
118     * @param schemaManager The Schema Manager
119     * @param normalizerDescription The Normalizer description object 
120     * @param targetRegistries The registries containing all the enabled SchemaObjects
121     * @param schemaName The schema this SchemaObject will be part of
122     * @return A new instance of a normalizer
123     * @throws LdapException If the creation has failed
124     */
125    Normalizer getNormalizer( SchemaManager schemaManager, NormalizerDescription normalizerDescription,
126        Registries targetRegistries, String schemaName ) throws LdapException;
127
128
129    /**
130     * Retrieve and load a Normalizer class from the DIT.
131     * 
132     * @param schemaManager The Schema Manager
133     * @param entry The entry containing all the informations to build a Normalizer
134     * @param targetRegistries The registries containing all the enabled SchemaObjects
135     * @param schemaName The schema this SchemaObject will be part of
136     * @return the loaded Normalizer
137     * @throws LdapException if anything fails during loading
138     */
139    Normalizer getNormalizer( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName )
140        throws LdapException;
141
142
143    /**
144     * 
145     * @param schemaManager The Schema Manager
146     * @param entry The entry containing all the informations to build an ObjectClass
147     * @param targetRegistries The registries containing all the enabled SchemaObjects
148     * @param schemaName The schema this SchemaObject will be part of
149     * @return The loaded ObjectClass
150     * @throws LdapException if anything fails during loading
151     */
152    ObjectClass getObjectClass( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName )
153        throws LdapException;
154
155
156    /**
157     * 
158     * @param schemaManager The Schema Manager
159     * @param entry The entry containing all the informations to build a LdapSyntax
160     * @param targetRegistries The registries containing all the enabled SchemaObjects
161     * @param schemaName The schema this SchemaObject will be part of
162     * @return The loaded Syntax
163     * @throws LdapException if anything fails during loading
164     */
165    LdapSyntax getSyntax( SchemaManager schemaManager, Entry entry, Registries targetRegistries, String schemaName )
166        throws LdapException;
167
168
169    /**
170     * Retrieve and load a syntaxChecker class from the DIT.
171     * 
172     * @param schemaManager The Schema Manager
173     * @param entry The entry containing all the informations to build a SyntaxChecker
174     * @param targetRegistries The registries containing all the enabled SchemaObjects
175     * @param schemaName The schema this SchemaObject will be part of
176     * @return the loaded SyntaxChecker
177     * @throws LdapException if anything fails during loading
178     */
179    SyntaxChecker getSyntaxChecker( SchemaManager schemaManager, Entry entry, Registries targetRegistries,
180        String schemaName ) throws LdapException;
181
182
183    /**
184     * Create a new instance of a SyntaxChecker 
185     *
186     * @param schemaManager The Schema Manager
187     * @param syntaxCheckerDescription The SyntaxChecker description object 
188     * @param targetRegistries The registries containing all the enabled SchemaObjects
189     * @param schemaName The schema this SchemaObject will be part of
190     * @return A new instance of a syntaxChecker
191     * @throws LdapException If the creation has failed
192     */
193    SyntaxChecker getSyntaxChecker( SchemaManager schemaManager, SyntaxCheckerDescription syntaxCheckerDescription,
194        Registries targetRegistries, String schemaName ) throws LdapException;
195}