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
-
-
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 void
addMappingFor(AttributeType attributeType)
Add a new Oid/Normalizer couple in the OidNormalizer mapvoid
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.AttributeTypeRegistry
copy()
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.AttributeType
get(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.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 attribute has descendants.boolean
hasDescendants(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.AttributeType
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(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 mapvoid
renameSchema(String originalSchemaName, String newSchemaName)
Modify all the SchemaObject using a schemaName when this name changes.int
size()
String
toString()
AttributeType
unregister(String numericOid)
Removes the SchemaObject registered with this registry, using its numeric OID.AttributeType
unregister(AttributeType schemaObject)
Removes the SchemaObject registered with this registry.void
unregisterDescendants(AttributeType attributeType, AttributeType ancestor)
Remove the AttributeType from the map associating an AttributeType 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, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
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:
getNormalizerMapping
in 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:
hasDescendants
in 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:
hasDescendants
in 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:
descendants
in 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:
descendants
in 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:
register
in 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:
registerDescendants
in 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:
unregisterDescendants
in 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:
unregister
in 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:
addMappingFor
in 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:
removeMappingFor
in 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:
lookup
in 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:
copy
in interfaceAttributeTypeRegistry
- Specified by:
copy
in interfaceSchemaObjectRegistry<AttributeType>
- Returns:
- The copied AttributeTypeRegistry
-
size
public int size()
- Specified by:
size
in 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:
iterator
in interfaceIterable<AttributeType>
- Specified by:
iterator
in 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:
oidsIterator
in 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:
contains
in 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:
getOidByName
in 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:
getSchemaName
in 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:
getType
in 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:
renameSchema
in 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:
unregisterSchemaElements
in 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:
get
in interfaceSchemaObjectRegistry<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 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:
unregister
in interfaceSchemaObjectRegistry<AttributeType>
- Parameters:
schemaObject
- the schemaObject to unregister- Returns:
- The unregistred schema object
- Throws:
LdapException
- if the schemaObject can't be unregistered is invalid
-
-