Class ImmutableComparatorRegistry
- java.lang.Object
-
- org.apache.directory.api.ldap.model.schema.registries.ImmutableComparatorRegistry
-
- All Implemented Interfaces:
Iterable<LdapComparator<?>>
,ComparatorRegistry
,SchemaObjectRegistry<LdapComparator<?>>
public class ImmutableComparatorRegistry extends Object implements ComparatorRegistry
An immutable wrapper of the Comparator registry.- Author:
- Apache Directory Project
-
-
Constructor Summary
Constructors Constructor Description ImmutableComparatorRegistry(ComparatorRegistry comparatorRegistry)
Creates a new immutable ComparatorRegistry instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the registry from all its contentboolean
contains(String oid)
Checks to see if an SchemaObject exists in the registry, by its OID or name.ImmutableComparatorRegistry
copy()
Copy the ComparatorRegistryLdapComparator<?>
get(String oid)
Gets the SchemaObject associated with a given OID.String
getOidByName(String name)
Gets the numericOid for a name/alias if one is associated.String
getSchemaName(String oid)
Gets the name of the schema this schema object is associated with.SchemaObjectType
getType()
Iterator<LdapComparator<?>>
iterator()
Gets an iterator over the registered schema objects in the registry.LdapComparator<?>
lookup(String oid)
Looks up a SchemaObject by its unique Object Identifier or by name.Iterator<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(String originalSchemaName, String newSchemaName)
Modify all the SchemaObject using a schemaName when this name changes.int
size()
LdapComparator<?>
unregister(String numericOid)
Removes the LdapComparator registered with this registry, using its numeric OID.LdapComparator<?>
unregister(LdapComparator<?> schemaObject)
Removes the SchemaObject registered with this registry.void
unregisterSchemaElements(String schemaName)
Unregisters all LdapComparators defined for a specific schema from this registry.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ImmutableComparatorRegistry
public ImmutableComparatorRegistry(ComparatorRegistry comparatorRegistry)
Creates a new immutable ComparatorRegistry instance.- Parameters:
comparatorRegistry
- 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 interfaceComparatorRegistry
- Specified by:
register
in interfaceSchemaObjectRegistry<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(String numericOid) throws LdapException
Removes the LdapComparator registered with this registry, using its numeric OID.- Specified by:
unregister
in interfaceComparatorRegistry
- Specified by:
unregister
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Parameters:
numericOid
- the numeric identifier- Returns:
- The unregistred schema object
- Throws:
LdapException
- if the numeric identifier is invalid
-
unregisterSchemaElements
public void unregisterSchemaElements(String schemaName) throws LdapException
Unregisters all LdapComparators defined for a specific schema from this registry.- Specified by:
unregisterSchemaElements
in interfaceComparatorRegistry
- Specified by:
unregisterSchemaElements
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Parameters:
schemaName
- the name of the schema whose LdapComparators will be removed from- Throws:
LdapException
- If we had a problem while unregistering the schema
-
copy
public ImmutableComparatorRegistry copy()
Copy the ComparatorRegistry- Specified by:
copy
in interfaceComparatorRegistry
- Specified by:
copy
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Returns:
- The copied registry
-
size
public int size()
- Specified by:
size
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Returns:
- The number of AttributeType stored
-
contains
public boolean contains(String oid)
Checks to see if an SchemaObject exists in the registry, by its OID or name.- Specified by:
contains
in interfaceSchemaObjectRegistry<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 String getOidByName(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 interfaceSchemaObjectRegistry<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 String getSchemaName(String oid) throws LdapException
Gets the name of the schema this schema object is associated with.- Specified by:
getSchemaName
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Parameters:
oid
- the object identifier or the name- Returns:
- the schema name
- Throws:
LdapException
- if the schema object does not exist
-
getType
public SchemaObjectType getType()
- Specified by:
getType
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Returns:
- the type
-
iterator
public Iterator<LdapComparator<?>> iterator()
Gets an iterator over the registered schema objects in the registry.- Specified by:
iterator
in interfaceIterable<LdapComparator<?>>
- Specified by:
iterator
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Returns:
- an Iterator of homogeneous schema objects
-
lookup
public LdapComparator<?> lookup(String oid) throws LdapException
Looks up a SchemaObject by its unique Object Identifier or by name.- Specified by:
lookup
in interfaceSchemaObjectRegistry<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 Iterator<String> oidsIterator()
Gets an iterator over the registered schema objects'OID in the registry.- Specified by:
oidsIterator
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Returns:
- an Iterator of OIDs
-
renameSchema
public void renameSchema(String originalSchemaName, String newSchemaName) throws LdapException
Modify all the SchemaObject using a schemaName when this name changes.- Specified by:
renameSchema
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Parameters:
originalSchemaName
- The original Schema namenewSchemaName
- The new Schema name- Throws:
LdapException
- if the schema object does not exist
-
get
public LdapComparator<?> get(String oid)
Gets the SchemaObject associated with a given OID.- Specified by:
get
in interfaceSchemaObjectRegistry<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 interfaceSchemaObjectRegistry<LdapComparator<?>>
- Throws:
LdapException
- If we had a failure while clearing the registry
-
unregister
public LdapComparator<?> unregister(LdapComparator<?> schemaObject) throws LdapException
Removes the SchemaObject registered with this registry.- Specified by:
unregister
in interfaceSchemaObjectRegistry<LdapComparator<?>>
- Parameters:
schemaObject
- the schemaObject to unregister- Returns:
- The unregistred schema object
- Throws:
LdapException
- if the schemaObject can't be unregistered is invalid
-
-