org.apache.directory.server.schema.registries
Class DefaultOidRegistry

java.lang.Object
  extended by org.apache.directory.server.schema.registries.DefaultOidRegistry
All Implemented Interfaces:
OidRegistry

public class DefaultOidRegistry
extends java.lang.Object
implements OidRegistry

Default OID registry implementation used to resolve a schema object OID to a name and vice-versa.
We are storing the schema elements in two data structures :

  • an oid to names map
  • a name to oid map

  • The first data structure contains a list of names associated with the given oid. The oid itself is not necessarily stored in this list, unless the schema object does not have any name.
    The second data structure contains all the names with the associated OID. We also store the oid -> oid relation, to allow us to look for a registered schema object using its oid.

    For instance, if we have registered the C AttributeType, which OID is 2.5.4.6 and has another name, 'country', the data structure will contain :

    Version:
    $Rev: 777089 $
    Author:
    Apache Directory Project

    Constructor Summary
    DefaultOidRegistry()
               
     
    Method Summary
     java.util.Map<java.lang.String,java.util.List<java.lang.String>> getNameByOid()
              Get the map of all the oids by their name
     java.util.List<java.lang.String> getNameSet(java.lang.String oid)
              Gets the names associated with an OID.
     java.lang.String getOid(java.lang.String name)
              Gets the object identifier for a common name or returns the argument as-is if it is an object identifier.
     java.util.Map<java.lang.String,java.lang.String> getOidByName()
              Get the map of all the oids by their name
     java.lang.String getPrimaryName(java.lang.String oid)
              Gets the primary name associated with an OID.
     boolean hasOid(java.lang.String name)
              Checks to see if an identifier, oid or name exists within this registry.
     java.util.Iterator<java.lang.String> list()
              Lists all the OIDs within the registry.
     void register(java.lang.String name, java.lang.String oid)
              Adds an OID name pair to the registry.
     void unregister(java.lang.String numericOid)
              Removes an oid from this registry.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    DefaultOidRegistry

    public DefaultOidRegistry()
    Method Detail

    getOid

    public java.lang.String getOid(java.lang.String name)
                            throws javax.naming.NamingException
    Gets the object identifier for a common name or returns the argument as-is if it is an object identifier.

    Specified by:
    getOid in interface OidRegistry
    Parameters:
    name - the name to lookup an OID for
    Returns:
    the OID string associated with a name
    Throws:
    javax.naming.NamingException - if name does not map to an OID

    hasOid

    public boolean hasOid(java.lang.String name)
    Checks to see if an identifier, oid or name exists within this registry.

    Specified by:
    hasOid in interface OidRegistry
    Parameters:
    name - the oid or name to look for
    Returns:
    true if the id exists false otherwise

    getPrimaryName

    public java.lang.String getPrimaryName(java.lang.String oid)
                                    throws javax.naming.NamingException
    Gets the primary name associated with an OID. The primary name is the first name specified for the OID.

    Specified by:
    getPrimaryName in interface OidRegistry
    Parameters:
    oid - the object identifier
    Returns:
    the primary name
    Throws:
    javax.naming.NamingException - if oid does not exist

    getNameSet

    public java.util.List<java.lang.String> getNameSet(java.lang.String oid)
                                                throws javax.naming.NamingException
    Gets the names associated with an OID. An OID is unique however it may have many names used to refer to it. A good example is the cn and commonName attribute names for OID 2.5.4.3. Within a server one name within the set must be chosen as the primary name. This is used to name certain things within the server internally. If there is more than one name then the first name is taken to be the primary.

    Specified by:
    getNameSet in interface OidRegistry
    Parameters:
    oid - the OID for which we return the set of common names
    Returns:
    a sorted set of names
    Throws:
    javax.naming.NamingException - if oid does not exist

    list

    public java.util.Iterator<java.lang.String> list()
    Lists all the OIDs within the registry. This may be a really big list.

    Specified by:
    list in interface OidRegistry
    Returns:
    all the OIDs registered

    getOidByName

    public java.util.Map<java.lang.String,java.lang.String> getOidByName()
    Get the map of all the oids by their name

    Specified by:
    getOidByName in interface OidRegistry
    Returns:
    The Map that contains all the oids

    getNameByOid

    public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getNameByOid()
    Get the map of all the oids by their name

    Specified by:
    getNameByOid in interface OidRegistry
    Returns:
    The Map that contains all the oids

    register

    public void register(java.lang.String name,
                         java.lang.String oid)
                  throws javax.naming.NamingException
    Adds an OID name pair to the registry.

    Specified by:
    register in interface OidRegistry
    Parameters:
    name - the name to associate with the OID
    oid - the OID to add or associate a new name with
    Throws:
    javax.naming.NamingException

    unregister

    public void unregister(java.lang.String numericOid)
                    throws javax.naming.NamingException
    Removes an oid from this registry.

    Specified by:
    unregister in interface OidRegistry
    Parameters:
    numericOid - the numeric identifier for the object
    Throws:
    javax.naming.NamingException - if the identifier is not numeric


    Copyright © 2003-2009 The Apache Software Foundation. All Rights Reserved.