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 package org.apache.directory.server.schema.registries;
21
22
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.Map;
26
27 import javax.naming.NamingException;
28
29
30 /**
31 * Object identifier registry.
32 *
33 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34 * @version $Rev: 568070 $
35 */
36 public interface OidRegistry
37 {
38 /**
39 * Gets the object identifier for a common name or returns the argument
40 * as-is if it is an object identifier.
41 *
42 * @param name the name to lookup an OID for
43 * @return the OID string associated with a name
44 * @throws NamingException if name does not map to an OID
45 */
46 String getOid( String name ) throws NamingException;
47
48
49 /**
50 * Checks to see if an identifier, oid or name exists within this registry.
51 *
52 * @param id the oid or name to look for
53 * @return true if the id exists false otherwise
54 */
55 boolean hasOid( String id );
56
57
58 /**
59 * Gets the primary name associated with an OID. The primary name is the
60 * first name specified for the OID.
61 *
62 * @param oid the object identifier
63 * @return the primary name
64 * @throws NamingException if oid does not exist
65 */
66 String getPrimaryName( String oid ) throws NamingException;
67
68
69 /**
70 * Gets the names associated with an OID. An OID is unique however it may
71 * have many names used to refer to it. A good example is the cn and
72 * commonName attribute names for OID 2.5.4.3. Within a server one name
73 * within the set must be chosen as the primary name. This is used to
74 * name certain things within the server internally. If there is more than
75 * one name then the first name is taken to be the primary.
76 *
77 * @param oid the OID for which we return the set of common names
78 * @return a sorted set of names
79 * @throws NamingException if oid does not exist
80 */
81 List getNameSet( String oid ) throws NamingException;
82
83
84 /**
85 * Lists all the OIDs within the registry. This may be a really big list.
86 *
87 * @return all the OIDs registered
88 */
89 Iterator list();
90
91
92 /**
93 * Adds an OID name pair to the registry.
94 *
95 * @param name the name to associate with the OID
96 * @param oid the OID to add or associate a new name with
97 */
98 void register( String name, String oid ) throws NamingException;
99
100
101 /**
102 * Get the map of all the oids by their name
103 * @return The Map that contains all the oids
104 */
105 public Map getOidByName();
106
107
108 /**
109 * Get the map of all the oids by their name
110 * @return The Map that contains all the oids
111 */
112 public Map getNameByOid();
113
114
115 /**
116 * Removes an oid from this registry.
117 *
118 * @param numericOid the numeric identifier for the object
119 * @throws NamingException if the identifier is not numeric
120 */
121 void unregister( String numericOid ) throws NamingException;
122 }