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

java.lang.Object
  extended by org.apache.directory.shared.ldap.schema.registries.ImmutableComparatorRegistry
All Implemented Interfaces:
java.lang.Iterable<LdapComparator<?>>, ComparatorRegistry, SchemaObjectRegistry<LdapComparator<?>>

public class ImmutableComparatorRegistry
extends java.lang.Object
implements ComparatorRegistry

An immutable wrapper of the Comparator registry.

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

Constructor Summary
ImmutableComparatorRegistry(ComparatorRegistry comparatorRegistry)
          Creates a new immutable ComparatorRegistry instance.
 
Method Summary
 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.
 ImmutableComparatorRegistry copy()
          Copy the ComparatorRegistry
 SchemaObject get(java.lang.String oid)
          Gets the SchemaObject associated with a given OID.
 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()
          
 java.util.Iterator<LdapComparator<?>> iterator()
          Gets an iterator over the registered schema objects in the registry.
 LdapComparator<?> 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(LdapComparator<?> comparator)
          Registers a new LdapComparator with this registry.
 void renameSchema(java.lang.String originalSchemaName, java.lang.String newSchemaName)
          Modify all the SchemaObject using a schemaName when this name changes.
 int size()
          
 LdapComparator<?> unregister(LdapComparator<?> schemaObject)
          Removes the SchemaObject registered with this registry.
 LdapComparator<?> unregister(java.lang.String numericOid)
          Removes the LdapComparator registered with this registry, using its numeric OID.
 void unregisterSchemaElements(java.lang.String schemaName)
          Unregisters all LdapComparators defined for a specific schema from this registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImmutableComparatorRegistry

public ImmutableComparatorRegistry(ComparatorRegistry comparatorRegistry)
Creates a new immutable ComparatorRegistry instance.

Parameters:
The - wrapped LdapComparator registry
Method Detail

register

public void register(LdapComparator<?> comparator)
              throws LdapException
Registers a new LdapComparator with this registry.

Specified by:
register in interface ComparatorRegistry
Specified by:
register in interface SchemaObjectRegistry<LdapComparator<?>>
Parameters:
comparator - the LdapComparator to register
Throws:
LdapException - if the LdapComparator is already registered or the registration operation is not supported

unregister

public LdapComparator<?> unregister(java.lang.String numericOid)
                             throws LdapException
Removes the LdapComparator registered with this registry, using its numeric OID.

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

unregisterSchemaElements

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

Specified by:
unregisterSchemaElements in interface ComparatorRegistry
Specified by:
unregisterSchemaElements in interface SchemaObjectRegistry<LdapComparator<?>>
Parameters:
schemaName - the name of the schema whose LdapComparators will be removed from
Throws:
LdapException

copy

public ImmutableComparatorRegistry copy()
Copy the ComparatorRegistry

Specified by:
copy in interface ComparatorRegistry
Specified by:
copy in interface SchemaObjectRegistry<LdapComparator<?>>
Returns:
SchemaObjectRegistry The copied registry

size

public int size()

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

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<LdapComparator<?>>
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<LdapComparator<?>>
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<LdapComparator<?>>
Returns:
the schema name
Throws:
LdapException - if the schema object does not exist

getType

public SchemaObjectType getType()

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

iterator

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

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

lookup

public LdapComparator<?> 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<LdapComparator<?>>
Parameters:
oid - the object identifier or name
Returns:
the SchemaObject instance for the id
Throws:
LdapException - if the SchemaObject does not exist

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<LdapComparator<?>>
Returns:
an Iterator of OIDs

renameSchema

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

Specified by:
renameSchema in interface SchemaObjectRegistry<LdapComparator<?>>
Parameters:
originalSchemaName - The original Schema name
newSchemaName - The new Schema name
Throws:
LdapException - if the schema object does not exist

get

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

Specified by:
get in interface SchemaObjectRegistry<LdapComparator<?>>
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<LdapComparator<?>>
Throws:
LdapException

unregister

public LdapComparator<?> unregister(LdapComparator<?> schemaObject)
                             throws LdapException
Removes the SchemaObject registered with this registry.

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


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