Class ImmutableAttributeTypeRegistry
- java.lang.Object
-
- org.apache.directory.api.ldap.model.schema.registries.ImmutableAttributeTypeRegistry
-
- All Implemented Interfaces:
Iterable<AttributeType>,AttributeTypeRegistry,SchemaObjectRegistry<AttributeType>
public class ImmutableAttributeTypeRegistry extends Object implements AttributeTypeRegistry
An immutable wrapper of the AttributeType registry.- Author:
- Apache Directory Project
-
-
Field Summary
Fields Modifier and Type Field Description (package private) AttributeTypeRegistryimmutableAttributeTypeRegistryThe wrapped AttributeType registry
-
Constructor Summary
Constructors Constructor Description ImmutableAttributeTypeRegistry(AttributeTypeRegistry attributeTypeRegistry)Creates a new instance of ImmutableAttributeTypeRegistry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMappingFor(AttributeType attributeType)Add a new Oid/Normalizer couple in the OidNormalizer mapvoidclear()Clear the registry from all its contentbooleancontains(String oid)Checks to see if an SchemaObject exists in the registry, by its OID or name.AttributeTypeRegistrycopy()Copy the AttributeTypeRegistryIterator<AttributeType>descendants(String ancestorId)Get's an iterator over the set of descendant attributeTypes for some ancestor's name alias or their OID.Iterator<AttributeType>descendants(AttributeType ancestor)Get's an iterator over the set of descendant attributeTypes for some ancestor's name alias or their OID.AttributeTypeget(String oid)Gets the SchemaObject associated with a given OID.Map<String,OidNormalizer>getNormalizerMapping()Gets an oid/name to normalizer mapping used to normalize distinguished names.StringgetOidByName(String name)Gets the numericOid for a name/alias if one is associated.StringgetSchemaName(String oid)Gets the name of the schema this schema object is associated with.SchemaObjectTypegetType()booleanhasDescendants(String ancestorId)Quick lookup to see if an attribute has descendants.booleanhasDescendants(AttributeType ancestor)Quick lookup to see if an attribute has descendants.Iterator<AttributeType>iterator()Gets an iterator over the registered schema objects in the registry.AttributeTypelookup(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.voidregister(AttributeType attributeType)Registers a new SchemaObject with this registry.voidregisterDescendants(AttributeType attributeType, AttributeType ancestor)Store the AttributeType into a map associating an AttributeType to its descendants.voidremoveMappingFor(AttributeType attributeType)Remove a new Oid/Normalizer couple in the OidNormalizer mapvoidrenameSchema(String originalSchemaName, String newSchemaName)Modify all the SchemaObject using a schemaName when this name changes.intsize()StringtoString()AttributeTypeunregister(String numericOid)Removes the SchemaObject registered with this registry, using its numeric OID.AttributeTypeunregister(AttributeType schemaObject)Removes the SchemaObject registered with this registry.voidunregisterDescendants(AttributeType attributeType, AttributeType ancestor)Remove the AttributeType from the map associating an AttributeType to its descendants.voidunregisterSchemaElements(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
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
immutableAttributeTypeRegistry
AttributeTypeRegistry immutableAttributeTypeRegistry
The wrapped AttributeType registry
-
-
Constructor Detail
-
ImmutableAttributeTypeRegistry
public ImmutableAttributeTypeRegistry(AttributeTypeRegistry attributeTypeRegistry)
Creates a new instance of ImmutableAttributeTypeRegistry.- Parameters:
attributeTypeRegistry- The wrapped AttributeType registry
-
-
Method Detail
-
getNormalizerMapping
public Map<String,OidNormalizer> getNormalizerMapping()
Gets an oid/name to normalizer mapping used to normalize distinguished names.- Specified by:
getNormalizerMappingin interfaceAttributeTypeRegistry- Returns:
- a map of OID Strings to OidNormalizer instances
-
hasDescendants
public boolean hasDescendants(String ancestorId) throws LdapException
Quick lookup to see if an attribute has descendants.- Specified by:
hasDescendantsin interfaceAttributeTypeRegistry- 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
-
hasDescendants
public boolean hasDescendants(AttributeType ancestor) throws LdapException
Quick lookup to see if an attribute has descendants.- Specified by:
hasDescendantsin interfaceAttributeTypeRegistry- Parameters:
ancestor- the attributeType we are looking for- 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 Iterator<AttributeType> descendants(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:
descendantsin interfaceAttributeTypeRegistry- 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 Iterator<AttributeType> descendants(AttributeType ancestor) throws LdapException
Get's an iterator over the set of descendant attributeTypes for some ancestor's name alias or their OID.- Specified by:
descendantsin interfaceAttributeTypeRegistry- Parameters:
ancestor- the AttributeType we are looking for- 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:
registerin interfaceSchemaObjectRegistry<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:
registerDescendantsin interfaceAttributeTypeRegistry- Parameters:
attributeType- The attributeType to registerancestor- The attributeType's parent- 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:
unregisterDescendantsin interfaceAttributeTypeRegistry- Parameters:
attributeType- The attributeType to unregisterancestor- its ancestor- Throws:
LdapException- If something went wrong
-
unregister
public AttributeType unregister(String numericOid) throws LdapException
Removes the SchemaObject registered with this registry, using its numeric OID.- Specified by:
unregisterin interfaceSchemaObjectRegistry<AttributeType>- Parameters:
numericOid- the numeric identifier- Returns:
- The unregistred schema object
- 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:
addMappingForin interfaceAttributeTypeRegistry- Parameters:
attributeType- The AttributeType to add- Throws:
LdapException- If something went wrong
-
removeMappingFor
public void removeMappingFor(AttributeType attributeType) throws LdapException
Remove a new Oid/Normalizer couple in the OidNormalizer map- Specified by:
removeMappingForin interfaceAttributeTypeRegistry- Parameters:
attributeType- The AttributeType to remove- Throws:
LdapException- If something went wrong
-
lookup
public AttributeType lookup(String oid) throws LdapException
Looks up a SchemaObject by its unique Object Identifier or by name.- Specified by:
lookupin interfaceSchemaObjectRegistry<AttributeType>- Parameters:
oid- the object identifier or name- Returns:
- the SchemaObject instance for the id
- Throws:
LdapException- if the SchemaObject does not exist
-
copy
public AttributeTypeRegistry copy()
Copy the AttributeTypeRegistry- Specified by:
copyin interfaceAttributeTypeRegistry- Specified by:
copyin interfaceSchemaObjectRegistry<AttributeType>- Returns:
- The copied AttributeTypeRegistry
-
size
public int size()
- Specified by:
sizein interfaceSchemaObjectRegistry<AttributeType>- Returns:
- The number of AttributeType stored
-
iterator
public Iterator<AttributeType> iterator()
Gets an iterator over the registered schema objects in the registry.- Specified by:
iteratorin interfaceIterable<AttributeType>- Specified by:
iteratorin interfaceSchemaObjectRegistry<AttributeType>- Returns:
- an Iterator of homogeneous schema objects
-
oidsIterator
public Iterator<String> oidsIterator()
Gets an iterator over the registered schema objects'OID in the registry.- Specified by:
oidsIteratorin interfaceSchemaObjectRegistry<AttributeType>- Returns:
- an Iterator of OIDs
-
contains
public boolean contains(String oid)
Checks to see if an SchemaObject exists in the registry, by its OID or name.- Specified by:
containsin interfaceSchemaObjectRegistry<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 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:
getOidByNamein interfaceSchemaObjectRegistry<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 String getSchemaName(String oid) throws LdapException
Gets the name of the schema this schema object is associated with.- Specified by:
getSchemaNamein interfaceSchemaObjectRegistry<AttributeType>- 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:
getTypein interfaceSchemaObjectRegistry<AttributeType>- Returns:
- the type
-
renameSchema
public void renameSchema(String originalSchemaName, String newSchemaName)
Modify all the SchemaObject using a schemaName when this name changes.- Specified by:
renameSchemain interfaceSchemaObjectRegistry<AttributeType>- Parameters:
originalSchemaName- The original Schema namenewSchemaName- The new Schema name
-
unregisterSchemaElements
public void unregisterSchemaElements(String schemaName) throws LdapException
Unregisters all SchemaObjects defined for a specific schema from this registry.- Specified by:
unregisterSchemaElementsin interfaceSchemaObjectRegistry<AttributeType>- 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 AttributeType get(String oid)
Gets the SchemaObject associated with a given OID.- Specified by:
getin interfaceSchemaObjectRegistry<AttributeType>- Parameters:
oid- The SchemaObject's OID we are looking for- Returns:
- The SchemaObject, if any. Null otherwise
-
clear
public void clear() throws LdapExceptionClear the registry from all its content- Specified by:
clearin interfaceSchemaObjectRegistry<AttributeType>- Throws:
LdapException- If we had a failure while clearing the registry
-
unregister
public AttributeType unregister(AttributeType schemaObject) throws LdapException
Removes the SchemaObject registered with this registry.- Specified by:
unregisterin interfaceSchemaObjectRegistry<AttributeType>- Parameters:
schemaObject- the schemaObject to unregister- Returns:
- The unregistred schema object
- Throws:
LdapException- if the schemaObject can't be unregistered is invalid
-
-