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
021package org.apache.directory.api.ldap.model.schema.normalizers;
022
023
024import org.apache.directory.api.ldap.model.exception.LdapException;
025
026
027/**
028 * Normalizers of ldap name component attributes and their values.
029 * 
030 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031 */
032public interface NameComponentNormalizer
033{
034    /**
035     * Checks to see if an attribute name/oid is defined.
036     * 
037     * @param id
038     *            the name/oid of the attribute to see if it is defined
039     * @return true if it is, false otherwise
040     */
041    boolean isDefined( String id );
042
043
044    /**
045     * Normalizes the attribute name/alias to use the OID for it instead.
046     * 
047     * @param attributeName the name or OID of the attributeType
048     * @return the OID of the attributeType if it is recognized
049     * @throws LdapException if the attributeName is not recognized as a valid alias
050     */
051    String normalizeName( String attributeName ) throws LdapException;
052
053
054    /**
055     * Normalizes an attribute's value given the name of the attribute - short
056     * names like 'cn' as well as 'commonName' should work here.
057     * 
058     * @param attributeName
059     *            the name of the attribute
060     * @param value
061     *            the value of the attribute to normalize
062     * @return the normalized value
063     * @throws LdapException
064     *             if there is a recognition problem or a syntax issue
065     */
066    Object normalizeByName( String attributeName, String value ) throws LdapException;
067
068
069    /**
070     * Normalizes an attribute's value given the name of the attribute - short
071     * names like 'cn' as well as 'commonName' should work here.
072     * 
073     * @param attributeName
074     *            the name of the attribute
075     * @param value
076     *            the value of the attribute to normalize
077     * @return the normalized value
078     * @throws LdapException
079     *             if there is a recognition problem or a syntax issue
080     */
081    Object normalizeByName( String attributeName, byte[] value ) throws LdapException;
082
083
084    /**
085     * Normalizes an attribute's value given the OID of the attribute.
086     * 
087     * @param attributeOid
088     *            the OID of the attribute
089     * @param value
090     *            the value of the attribute to normalize
091     * @return the normalized value
092     * @throws LdapException
093     *             if there is a recognition problem or a syntax issue
094     */
095    Object normalizeByOid( String attributeOid, String value ) throws LdapException;
096
097
098    /**
099     * Normalizes an attribute's value given the OID of the attribute.
100     * 
101     * @param attributeOid
102     *            the OID of the attribute
103     * @param value
104     *            the value of the attribute to normalize
105     * @return the normalized value
106     * @throws LdapException
107     *             if there is a recognition problem or a syntax issue
108     */
109    Object normalizeByOid( String attributeOid, byte[] value ) throws LdapException;
110}