Class ImmutableObjectClassRegistry
- java.lang.Object
-
- org.apache.directory.api.ldap.model.schema.registries.ImmutableObjectClassRegistry
-
- All Implemented Interfaces:
Cloneable
,Iterable<ObjectClass>
,ObjectClassRegistry
,SchemaObjectRegistry<ObjectClass>
public class ImmutableObjectClassRegistry extends Object implements ObjectClassRegistry, Cloneable
An immutable wrapper of the ObjectClass registry.- Author:
- Apache Directory Project
-
-
Constructor Summary
Constructors Constructor Description ImmutableObjectClassRegistry(ObjectClassRegistry ocRegistry)
Creates a new instance of ImmutableAttributeTypeRegistry.
-
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.ImmutableObjectClassRegistry
copy()
Clone the ObjectClassRegistryIterator<ObjectClass>
descendants(String ancestorId)
Get's an iterator over the set of descendant ObjectClasses for some ancestor's name alias or their OID.ObjectClass
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()
boolean
hasDescendants(String ancestorId)
Quick lookup to see if an objectClass has descendants.Iterator<ObjectClass>
iterator()
Gets an iterator over the registered schema objects in the registry.ObjectClass
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(ObjectClass objectClass)
Registers a new ObjectClass with this registry.void
registerDescendants(ObjectClass objectClass, List<ObjectClass> ancestors)
Store the ObjectClass into a map associating an ObjectClass to its descendants.void
renameSchema(String originalSchemaName, String newSchemaName)
Modify all the SchemaObject using a schemaName when this name changes.int
size()
ObjectClass
unregister(String numericOid)
Removes the ObjectClass registered with this registry.ObjectClass
unregister(ObjectClass schemaObject)
Removes the SchemaObject registered with this registry.void
unregisterDescendants(ObjectClass attributeType, List<ObjectClass> ancestors)
Remove the ObjectClass from the map associating an ObjectClass to its descendants.void
unregisterSchemaElements(String schemaName)
Unregisters all SchemaObjects 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
-
ImmutableObjectClassRegistry
public ImmutableObjectClassRegistry(ObjectClassRegistry ocRegistry)
Creates a new instance of ImmutableAttributeTypeRegistry.- Parameters:
ocRegistry
- The wrapped Attrib uteType registry
-
-
Method Detail
-
hasDescendants
public boolean hasDescendants(String ancestorId) throws LdapException
Quick lookup to see if an objectClass has descendants.- Specified by:
hasDescendants
in interfaceObjectClassRegistry
- Parameters:
ancestorId
- the name alias or OID for an ObjectClass- Returns:
- an Iterator over the ObjectClasses which have the ancestor within their superior chain to the top
- Throws:
LdapException
- if the ancestor ObjectClass cannot be discerned from the ancestorId supplied
-
descendants
public Iterator<ObjectClass> descendants(String ancestorId) throws LdapException
Get's an iterator over the set of descendant ObjectClasses for some ancestor's name alias or their OID.- Specified by:
descendants
in interfaceObjectClassRegistry
- Parameters:
ancestorId
- the name alias or OID for an ObjectClass- Returns:
- an Iterator over the ObjectClasses which have the ancestor within their superior chain to the top
- Throws:
LdapException
- if the ancestor ObjectClass cannot be discerned from the ancestorId supplied
-
registerDescendants
public void registerDescendants(ObjectClass objectClass, List<ObjectClass> ancestors) throws LdapException
Store the ObjectClass into a map associating an ObjectClass to its descendants.- Specified by:
registerDescendants
in interfaceObjectClassRegistry
- Parameters:
objectClass
- The ObjectClass to registerancestors
- Its ancestors- Throws:
LdapException
- If something went wrong
-
unregisterDescendants
public void unregisterDescendants(ObjectClass attributeType, List<ObjectClass> ancestors) throws LdapException
Remove the ObjectClass from the map associating an ObjectClass to its descendants.- Specified by:
unregisterDescendants
in interfaceObjectClassRegistry
- Parameters:
attributeType
- The ObjectClass to unregisterancestors
- its ancestors- Throws:
LdapException
- If something went wrong
-
register
public void register(ObjectClass objectClass) throws LdapException
Registers a new ObjectClass with this registry.- Specified by:
register
in interfaceObjectClassRegistry
- Specified by:
register
in interfaceSchemaObjectRegistry<ObjectClass>
- Parameters:
objectClass
- the ObjectClass to register- Throws:
LdapException
- if the ObjectClass is already registered or the registration operation is not supported
-
unregister
public ObjectClass unregister(String numericOid) throws LdapException
Removes the ObjectClass registered with this registry.- Specified by:
unregister
in interfaceObjectClassRegistry
- Specified by:
unregister
in interfaceSchemaObjectRegistry<ObjectClass>
- Parameters:
numericOid
- the numeric identifier- Returns:
- The unregistred schema object
- Throws:
LdapException
- if the numeric identifier is invalid
-
copy
public ImmutableObjectClassRegistry copy()
Clone the ObjectClassRegistry- Specified by:
copy
in interfaceObjectClassRegistry
- Specified by:
copy
in interfaceSchemaObjectRegistry<ObjectClass>
- Returns:
- The copied registry
-
size
public int size()
- Specified by:
size
in interfaceSchemaObjectRegistry<ObjectClass>
- 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<ObjectClass>
- 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<ObjectClass>
- 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<ObjectClass>
- 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<ObjectClass>
- Returns:
- the type
-
iterator
public Iterator<ObjectClass> iterator()
Gets an iterator over the registered schema objects in the registry.- Specified by:
iterator
in interfaceIterable<ObjectClass>
- Specified by:
iterator
in interfaceSchemaObjectRegistry<ObjectClass>
- Returns:
- an Iterator of homogeneous schema objects
-
lookup
public ObjectClass lookup(String oid) throws LdapException
Looks up a SchemaObject by its unique Object Identifier or by name.- Specified by:
lookup
in interfaceSchemaObjectRegistry<ObjectClass>
- 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<ObjectClass>
- 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<ObjectClass>
- Parameters:
originalSchemaName
- The original Schema namenewSchemaName
- The new Schema name- Throws:
LdapException
- if the schema object does not exist
-
unregisterSchemaElements
public void unregisterSchemaElements(String schemaName) throws LdapException
Unregisters all SchemaObjects defined for a specific schema from this registry.- Specified by:
unregisterSchemaElements
in interfaceSchemaObjectRegistry<ObjectClass>
- Parameters:
schemaName
- the name of the schema whose SchemaObjects will be removed from- Throws:
LdapException
- If we had a problem while unregistering the schema
-
get
public ObjectClass get(String oid)
Gets the SchemaObject associated with a given OID.- Specified by:
get
in interfaceSchemaObjectRegistry<ObjectClass>
- 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<ObjectClass>
- Throws:
LdapException
- If we had a failure while clearing the registry
-
unregister
public ObjectClass unregister(ObjectClass schemaObject) throws LdapException
Removes the SchemaObject registered with this registry.- Specified by:
unregister
in interfaceSchemaObjectRegistry<ObjectClass>
- Parameters:
schemaObject
- the schemaObject to unregister- Returns:
- The unregistred schema object
- Throws:
LdapException
- if the schemaObject can't be unregistered is invalid
-
-