org.apache.directory.shared.ldap.schema.registries
Class ImmutableAttributeTypeRegistry

java.lang.Object
  extended by org.apache.directory.shared.ldap.schema.registries.ImmutableAttributeTypeRegistry
All Implemented Interfaces:
java.lang.Iterable<AttributeType>, AttributeTypeRegistry, SchemaObjectRegistry<AttributeType>

public class ImmutableAttributeTypeRegistry
extends java.lang.Object
implements AttributeTypeRegistry

An immutable wrapper of the AttributeType registry.

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

Constructor Summary
ImmutableAttributeTypeRegistry(AttributeTypeRegistry attributeTypeRegistry)
          Creates a new instance of ImmutableAttributeTypeRegistry.
 
Method Summary
 void addMappingFor(AttributeType attributeType)
          Add a new Oid/Normalizer couple in the OidNormalizer map
 void clear()
          Clear the registry from all its content
 boolean contains(java.lang.String oid)
          Checks to see if an SchemaObject exists in the registry, by its OID or name.
 AttributeTypeRegistry copy()
          Copy the AttributeTypeRegistry
 java.util.Iterator<AttributeType> descendants(java.lang.String ancestorId)
          Get's an iterator over the set of descendant attributeTypes for some ancestor's name alias or their OID.
 SchemaObject get(java.lang.String oid)
          Gets the SchemaObject associated with a given OID.
 java.util.Map<java.lang.String,OidNormalizer> getNormalizerMapping()
          Gets an oid/name to normalizer mapping used to normalize distinguished names.
 java.lang.String getOidByName(java.lang.String name)
          Gets the numericOid for a name/alias if one is associated.
 java.lang.String getSchemaName(java.lang.String oid)
          Gets the name of the schema this schema object is associated with.
 SchemaObjectType getType()
          
 boolean hasDescendants(java.lang.String ancestorId)
          Quick lookup to see if an attribute has descendants.
 java.util.Iterator<AttributeType> iterator()
          Gets an iterator over the registered schema objects in the registry.
 AttributeType lookup(java.lang.String oid)
          Looks up a SchemaObject by its unique Object Identifier or by name.
 java.util.Iterator<java.lang.String> oidsIterator()
          Gets an iterator over the registered schema objects'OID in the registry.
 void register(AttributeType attributeType)
          Registers a new SchemaObject with this registry.
 void registerDescendants(AttributeType attributeType, AttributeType ancestor)
          Store the AttributeType into a map associating an AttributeType to its descendants.
 void removeMappingFor(AttributeType attributeType)
          Remove a new Oid/Normalizer couple in the OidNormalizer map
 void renameSchema(java.lang.String originalSchemaName, java.lang.String newSchemaName)
          Modify all the SchemaObject using a schemaName when this name changes.
 int size()
          
 java.lang.String toString()
          
 AttributeType unregister(AttributeType schemaObject)
          Removes the SchemaObject registered with this registry.
 AttributeType unregister(java.lang.String numericOid)
          Removes the SchemaObject registered with this registry, using its numeric OID.
 void unregisterDescendants(AttributeType attributeType, AttributeType ancestor)
          Remove the AttributeType from the map associating an AttributeType to its descendants.
 void unregisterSchemaElements(java.lang.String schemaName)
          Unregisters all SchemaObjects defined for a specific schema from this registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImmutableAttributeTypeRegistry

public ImmutableAttributeTypeRegistry(AttributeTypeRegistry attributeTypeRegistry)
Creates a new instance of ImmutableAttributeTypeRegistry.

Parameters:
attributeTypeRegistry - The wrapped AttributeType registry
Method Detail

getNormalizerMapping

public java.util.Map<java.lang.String,OidNormalizer> getNormalizerMapping()
Gets an oid/name to normalizer mapping used to normalize distinguished names.

Specified by:
getNormalizerMapping in interface AttributeTypeRegistry
Returns:
a map of OID Strings to OidNormalizer instances

hasDescendants

public boolean hasDescendants(java.lang.String ancestorId)
                       throws LdapException
Quick lookup to see if an attribute has descendants.

Specified by:
hasDescendants in interface AttributeTypeRegistry
Parameters:
ancestorId - the name alias or OID for an attributeType
Returns:
an Iterator over the AttributeTypes which have the ancestor within their superior chain to the top
Throws:
LdapException - if the ancestor attributeType cannot be discerned from the ancestorId supplied

descendants

public java.util.Iterator<AttributeType> descendants(java.lang.String ancestorId)
                                              throws LdapException
Get's an iterator over the set of descendant attributeTypes for some ancestor's name alias or their OID.

Specified by:
descendants in interface AttributeTypeRegistry
Parameters:
ancestorId - the name alias or OID for an attributeType
Returns:
an Iterator over the AttributeTypes which have the ancestor within their superior chain to the top
Throws:
LdapException - if the ancestor attributeType cannot be discerned from the ancestorId supplied

register

public void register(AttributeType attributeType)
              throws LdapException
Registers a new SchemaObject with this registry.

Specified by:
register in interface SchemaObjectRegistry<AttributeType>
Parameters:
attributeType - the SchemaObject to register
Throws:
LdapException - if the SchemaObject is already registered or the registration operation is not supported

registerDescendants

public void registerDescendants(AttributeType attributeType,
                                AttributeType ancestor)
                         throws LdapException
Store the AttributeType into a map associating an AttributeType to its descendants.

Specified by:
registerDescendants in interface AttributeTypeRegistry
Parameters:
attributeType - The attributeType to register
Throws:
LdapException - If something went wrong

unregisterDescendants

public void unregisterDescendants(AttributeType attributeType,
                                  AttributeType ancestor)
                           throws LdapException
Remove the AttributeType from the map associating an AttributeType to its descendants.

Specified by:
unregisterDescendants in interface AttributeTypeRegistry
Parameters:
attributeType - The attributeType to unregister
ancestor - its ancestor
Throws:
LdapException - If something went wrong

unregister

public AttributeType unregister(java.lang.String numericOid)
                         throws LdapException
Removes the SchemaObject registered with this registry, using its numeric OID.

Specified by:
unregister in interface SchemaObjectRegistry<AttributeType>
Parameters:
numericOid - the numeric identifier
Throws:
LdapException - if the numeric identifier is invalid

addMappingFor

public void addMappingFor(AttributeType attributeType)
                   throws LdapException
Add a new Oid/Normalizer couple in the OidNormalizer map

Specified by:
addMappingFor in interface AttributeTypeRegistry
Throws:
LdapException

removeMappingFor

public void removeMappingFor(AttributeType attributeType)
                      throws LdapException
Remove a new Oid/Normalizer couple in the OidNormalizer map

Specified by:
removeMappingFor in interface AttributeTypeRegistry
Throws:
LdapException

lookup

public AttributeType lookup(java.lang.String oid)
                     throws LdapException
Looks up a SchemaObject by its unique Object Identifier or by name.

Specified by:
lookup in interface SchemaObjectRegistry<AttributeType>
Parameters:
oid - the object identifier or name
Returns:
the SchemaObject instance for the id
Throws:
LdapException - if the SchemaObject does not exist

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

copy

public AttributeTypeRegistry copy()
Copy the AttributeTypeRegistry

Specified by:
copy in interface AttributeTypeRegistry
Specified by:
copy in interface SchemaObjectRegistry<AttributeType>
Returns:
SchemaObjectRegistry The copied registry

size

public int size()

Specified by:
size in interface SchemaObjectRegistry<AttributeType>
Returns:
The number of AttributeType stored

iterator

public java.util.Iterator<AttributeType> iterator()
Gets an iterator over the registered schema objects in the registry.

Specified by:
iterator in interface java.lang.Iterable<AttributeType>
Specified by:
iterator in interface SchemaObjectRegistry<AttributeType>
Returns:
an Iterator of homogeneous schema objects

oidsIterator

public java.util.Iterator<java.lang.String> oidsIterator()
Gets an iterator over the registered schema objects'OID in the registry.

Specified by:
oidsIterator in interface SchemaObjectRegistry<AttributeType>
Returns:
an Iterator of OIDs

contains

public boolean contains(java.lang.String oid)
Checks to see if an SchemaObject exists in the registry, by its OID or name.

Specified by:
contains in interface SchemaObjectRegistry<AttributeType>
Parameters:
oid - the object identifier or name of the SchemaObject
Returns:
true if a SchemaObject definition exists for the oid, false otherwise

getOidByName

public java.lang.String getOidByName(java.lang.String name)
                              throws LdapException
Gets the numericOid for a name/alias if one is associated. To prevent lookup failures due to case variance in the name, a failure to lookup the OID, will trigger a lookup using a lower cased version of the name and the name that failed to match will automatically be associated with the OID.

Specified by:
getOidByName in interface SchemaObjectRegistry<AttributeType>
Parameters:
name - The name we are looking the oid for
Returns:
The numericOID associated with this name
Throws:
LdapException - If the OID can't be found

getSchemaName

public java.lang.String getSchemaName(java.lang.String oid)
                               throws LdapException
Gets the name of the schema this schema object is associated with.

Specified by:
getSchemaName in interface SchemaObjectRegistry<AttributeType>
Returns:
the schema name
Throws:
LdapException - if the schema object does not exist

getType

public SchemaObjectType getType()

Specified by:
getType in interface SchemaObjectRegistry<AttributeType>
Returns:
the type

renameSchema

public void renameSchema(java.lang.String originalSchemaName,
                         java.lang.String newSchemaName)
Modify all the SchemaObject using a schemaName when this name changes.

Specified by:
renameSchema in interface SchemaObjectRegistry<AttributeType>
Parameters:
originalSchemaName - The original Schema name
newSchemaName - The new Schema name

unregisterSchemaElements

public void unregisterSchemaElements(java.lang.String schemaName)
                              throws LdapException
Unregisters all SchemaObjects defined for a specific schema from this registry.

Specified by:
unregisterSchemaElements in interface SchemaObjectRegistry<AttributeType>
Parameters:
schemaName - the name of the schema whose SchemaObjects will be removed from
Throws:
LdapException

get

public SchemaObject get(java.lang.String oid)
Gets the SchemaObject associated with a given OID.

Specified by:
get in interface SchemaObjectRegistry<AttributeType>
Parameters:
oid - The SchemaObject's OID we are looking for
Returns:
The SchemaObject, if any. Null otherwise

clear

public void clear()
           throws LdapException
Clear the registry from all its content

Specified by:
clear in interface SchemaObjectRegistry<AttributeType>
Throws:
LdapException

unregister

public AttributeType unregister(AttributeType schemaObject)
                         throws LdapException
Removes the SchemaObject registered with this registry.

Specified by:
unregister in interface SchemaObjectRegistry<AttributeType>
Throws:
LdapException - if the schemaObject can't be unregistered is invalid


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.