Class DefaultSchemaObjectRegistry<T extends SchemaObject>
- java.lang.Object
-
- org.apache.directory.api.ldap.model.schema.registries.DefaultSchemaObjectRegistry<T>
-
- Type Parameters:
T- The type of SchemaObject
- All Implemented Interfaces:
Iterable<T>,SchemaObjectRegistry<T>
- Direct Known Subclasses:
DefaultAttributeTypeRegistry,DefaultComparatorRegistry,DefaultDitContentRuleRegistry,DefaultDitStructureRuleRegistry,DefaultLdapSyntaxRegistry,DefaultMatchingRuleRegistry,DefaultMatchingRuleUseRegistry,DefaultNameFormRegistry,DefaultNormalizerRegistry,DefaultObjectClassRegistry,DefaultSyntaxCheckerRegistry
public abstract class DefaultSchemaObjectRegistry<T extends SchemaObject> extends Object implements SchemaObjectRegistry<T>, Iterable<T>
Common schema object registry interface.- Author:
- Apache Directory Project
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,T>byNamea map of SchemaObject looked up by nameprotected OidRegistry<T>oidRegistrythe global OID Registryprotected SchemaObjectTypeschemaObjectTypeThe SchemaObject type, used by the toString() method
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultSchemaObjectRegistry(SchemaObjectType schemaObjectType, OidRegistry<T> oidRegistry)Creates a new DefaultSchemaObjectRegistry instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear the registry from all its contentbooleancontains(String oid)Checks to see if an SchemaObject exists in the registry, by its OID or name.SchemaObjectRegistry<T>copy(SchemaObjectRegistry<T> original)Copy a SchemaObject registryTget(String oid)Gets the SchemaObject associated with a given OID.SchemaErrorHandlergetErrorHandler()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()booleanisRelaxed()Tells if the Registry is permissive or if it must be checked against inconsistencies.booleanisStrict()Tells if the Registry is strict.Iterator<T>iterator()Gets an iterator over the registered schema objects in the registry.Tlookup(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(T schemaObject)Registers a new SchemaObject with this registry.voidrenameSchema(String originalSchemaName, String newSchemaName)Modify all the SchemaObject using a schemaName when this name changes.voidsetErrorHandler(SchemaErrorHandler errorHandler)voidsetRelaxed()Change the Registry to a relaxed mode, where invalid SchemaObjects can be registered.voidsetStrict()Change the Registry to a strict mode, where invalid SchemaObjects cannot be registered.intsize()StringtoString()Tunregister(String numericOid)Removes the SchemaObject registered with this registry, using its numeric OID.Tunregister(T schemaObject)Removes the SchemaObject registered with this registry.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
-
Methods inherited from interface org.apache.directory.api.ldap.model.schema.registries.SchemaObjectRegistry
copy
-
-
-
-
Field Detail
-
byName
protected Map<String,T extends SchemaObject> byName
a map of SchemaObject looked up by name
-
schemaObjectType
protected SchemaObjectType schemaObjectType
The SchemaObject type, used by the toString() method
-
oidRegistry
protected OidRegistry<T extends SchemaObject> oidRegistry
the global OID Registry
-
-
Constructor Detail
-
DefaultSchemaObjectRegistry
protected DefaultSchemaObjectRegistry(SchemaObjectType schemaObjectType, OidRegistry<T> oidRegistry)
Creates a new DefaultSchemaObjectRegistry instance.- Parameters:
schemaObjectType- The Schema Object typeoidRegistry- The OID registry to use
-
-
Method Detail
-
isRelaxed
public boolean isRelaxed()
Tells if the Registry is permissive or if it must be checked against inconsistencies.- Returns:
- True if SchemaObjects can be added even if they break the consistency
-
isStrict
public boolean isStrict()
Tells if the Registry is strict.- Returns:
- True if SchemaObjects cannot be added if they break the consistency
-
setRelaxed
public void setRelaxed()
Change the Registry to a relaxed mode, where invalid SchemaObjects can be registered.
-
setStrict
public void setStrict()
Change the Registry to a strict mode, where invalid SchemaObjects cannot be registered.
-
getErrorHandler
public SchemaErrorHandler getErrorHandler()
-
setErrorHandler
public void setErrorHandler(SchemaErrorHandler errorHandler)
-
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<T extends SchemaObject>- Parameters:
oid- the object identifier or name of the SchemaObject- Returns:
- true if a SchemaObject definition exists for the oid, false otherwise
-
getSchemaName
public String getSchemaName(String oid) throws LdapException
Gets the name of the schema this schema object is associated with.- Specified by:
getSchemaNamein interfaceSchemaObjectRegistry<T extends SchemaObject>- Parameters:
oid- the object identifier or the name- Returns:
- the schema name
- Throws:
LdapException- if the schema object does not exist
-
renameSchema
public void renameSchema(String originalSchemaName, String newSchemaName)
Modify all the SchemaObject using a schemaName when this name changes.- Specified by:
renameSchemain interfaceSchemaObjectRegistry<T extends SchemaObject>- Parameters:
originalSchemaName- The original Schema namenewSchemaName- The new Schema name
-
iterator
public Iterator<T> iterator()
Gets an iterator over the registered schema objects in the registry.- Specified by:
iteratorin interfaceIterable<T extends SchemaObject>- Specified by:
iteratorin interfaceSchemaObjectRegistry<T extends SchemaObject>- 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<T extends SchemaObject>- Returns:
- an Iterator of OIDs
-
lookup
public T lookup(String oid) throws LdapException
Looks up a SchemaObject by its unique Object Identifier or by name.- Specified by:
lookupin interfaceSchemaObjectRegistry<T extends SchemaObject>- Parameters:
oid- the object identifier or name- Returns:
- the SchemaObject instance for the id
- Throws:
LdapException- if the SchemaObject does not exist
-
register
public void register(T schemaObject) throws LdapException
Registers a new SchemaObject with this registry.- Specified by:
registerin interfaceSchemaObjectRegistry<T extends SchemaObject>- Parameters:
schemaObject- the SchemaObject to register- Throws:
LdapException- if the SchemaObject is already registered or the registration operation is not supported
-
unregister
public T unregister(String numericOid) throws LdapException
Removes the SchemaObject registered with this registry, using its numeric OID.- Specified by:
unregisterin interfaceSchemaObjectRegistry<T extends SchemaObject>- Parameters:
numericOid- the numeric identifier- Returns:
- The unregistred schema object
- Throws:
LdapException- if the numeric identifier is invalid
-
unregister
public T unregister(T schemaObject) throws LdapException
Removes the SchemaObject registered with this registry.- Specified by:
unregisterin interfaceSchemaObjectRegistry<T extends SchemaObject>- Parameters:
schemaObject- the schemaObject to unregister- Returns:
- The unregistred schema object
- Throws:
LdapException- if the schemaObject can't be unregistered is invalid
-
unregisterSchemaElements
public void unregisterSchemaElements(String schemaName) throws LdapException
Unregisters all SchemaObjects defined for a specific schema from this registry.- Specified by:
unregisterSchemaElementsin interfaceSchemaObjectRegistry<T extends SchemaObject>- Parameters:
schemaName- the name of the schema whose SchemaObjects will be removed from- Throws:
LdapException- If we had a problem while unregistering the schema
-
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<T extends SchemaObject>- 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
-
copy
public SchemaObjectRegistry<T> copy(SchemaObjectRegistry<T> original)
Copy a SchemaObject registry- Parameters:
original- The SchemaObject registry to copy- Returns:
- The copied ShcemaObject registry
-
get
public T get(String oid)
Gets the SchemaObject associated with a given OID.- Specified by:
getin interfaceSchemaObjectRegistry<T extends SchemaObject>- Parameters:
oid- The SchemaObject's OID we are looking for- Returns:
- The SchemaObject, if any. Null otherwise
-
getType
public SchemaObjectType getType()
- Specified by:
getTypein interfaceSchemaObjectRegistry<T extends SchemaObject>- Returns:
- the type
-
size
public int size()
- Specified by:
sizein interfaceSchemaObjectRegistry<T extends SchemaObject>- Returns:
- The number of AttributeType stored
-
toString
public String toString()
- Overrides:
toStringin classObject- See Also:
Object.toString()
-
clear
public void clear()
Clear the registry from all its content- Specified by:
clearin interfaceSchemaObjectRegistry<T extends SchemaObject>
-
-