View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  
21  package org.apache.directory.api.ldap.model.schema.normalizers;
22  
23  
24  import org.apache.directory.api.ldap.model.exception.LdapException;
25  
26  
27  /**
28   * Normalizers of ldap name component attributes and their values.
29   * 
30   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
31   */
32  public interface NameComponentNormalizer
33  {
34      /**
35       * Checks to see if an attribute name/oid is defined.
36       * 
37       * @param id
38       *            the name/oid of the attribute to see if it is defined
39       * @return true if it is, false otherwise
40       */
41      boolean isDefined( String id );
42  
43  
44      /**
45       * Normalizes the attribute name/alias to use the OID for it instead.
46       * 
47       * @param attributeName the name or OID of the attributeType
48       * @return the OID of the attributeType if it is recognized
49       * @throws LdapException if the attributeName is not recognized as a valid alias
50       */
51      String normalizeName( String attributeName ) throws LdapException;
52  
53  
54      /**
55       * Normalizes an attribute's value given the name of the attribute - short
56       * names like 'cn' as well as 'commonName' should work here.
57       * 
58       * @param attributeName
59       *            the name of the attribute
60       * @param value
61       *            the value of the attribute to normalize
62       * @return the normalized value
63       * @throws LdapException
64       *             if there is a recognition problem or a syntax issue
65       */
66      Object normalizeByName( String attributeName, String value ) throws LdapException;
67  
68  
69      /**
70       * Normalizes an attribute's value given the name of the attribute - short
71       * names like 'cn' as well as 'commonName' should work here.
72       * 
73       * @param attributeName
74       *            the name of the attribute
75       * @param value
76       *            the value of the attribute to normalize
77       * @return the normalized value
78       * @throws LdapException
79       *             if there is a recognition problem or a syntax issue
80       */
81      Object normalizeByName( String attributeName, byte[] value ) throws LdapException;
82  
83  
84      /**
85       * Normalizes an attribute's value given the OID of the attribute.
86       * 
87       * @param attributeOid
88       *            the OID of the attribute
89       * @param value
90       *            the value of the attribute to normalize
91       * @return the normalized value
92       * @throws LdapException
93       *             if there is a recognition problem or a syntax issue
94       */
95      Object normalizeByOid( String attributeOid, String value ) throws LdapException;
96  
97  
98      /**
99       * 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 }