All LDAP Classes
Internal LDAP Classes

com.novell.ldap
Class LDAPSchema

java.lang.Object
  extended by com.novell.ldap.LDAPEntry
      extended by com.novell.ldap.LDAPSchema
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Comparable

public class LDAPSchema
extends LDAPEntry

Represents a schema entry that controls one or more entries held by a Directory Server.

LDAPSchema Contains methods to parse schema attributes into individual schema definitions, represented by subclasses of LDAPSchemaElement. Schema may be retrieved from a Directory server with the fetchSchema method of LDAPConnection or by creating an LDAPEntry containing schema attributes. The following sample code demonstrates how to retrieve schema elements from LDAPSchema


      .
      .
      .
      LDAPSchema schema;
      LDAPSchemaElement element;

      // connect to the server
      lc.connect( ldapHost, ldapPort );
      lc.bind( ldapVersion, loginDN, password );

      // read the schema from the directory
      schema = lc.fetchSchema( lc.getSchemaDN() );

      // retrieve the definition of common name
      element = schema.getAttributeSchema( "cn" );
      System.out.println("The attribute cn has an oid of " + element.getID());
      .
      .
      .
 

Other sample code:

Adding and deleting Schema.
ExtendSchema.java
Modifing an existing schema element
MakeContainer.java
Listing schema in a GUI
ListSchema.java
ListAttributeSchema.java
ListObjectClassSchema.java

See Also:
LDAPSchemaElement, LDAPConnection.fetchSchema(java.lang.String), LDAPConnection.getSchemaDN(), Serialized Form

Field Summary
(package private) static int ATTRIBUTE
          An index into the the arrays schemaTypeNames, idTable, and nameTable
(package private) static int DITCONTENT
          An index into the the arrays schemaTypeNames, idTable, and nameTable
(package private) static int DITSTRUCTURE
          An index into the the arrays schemaTypeNames, idTable, and nameTable
private  java.util.HashMap[] idTable
          The idTable hash on the oid (or integer ID for DITStructureRule) and is used for retrieving enumerations
(package private) static int MATCHING
          An index into the the arrays schemaTypeNames, idTable, and nameTable
(package private) static int MATCHING_USE
          An index into the the arrays schemaTypeNames, idTable, and nameTable
(package private) static int NAME_FORM
          An index into the the arrays schemaTypeNames, idTable, and nameTable
private  java.util.HashMap[] nameTable
          The nameTable will hash on the names (if available).
(package private) static int OBJECT_CLASS
          An index into the the arrays schemaTypeNames, idTable, and nameTable
(package private) static java.lang.String[] schemaTypeNames
          The following lists the LDAP names of subschema attributes for schema elements (definitions):
(package private) static int SYNTAX
          An index into the the arrays schemaTypeNames, idTable, and nameTable
 
Fields inherited from class com.novell.ldap.LDAPEntry
attrs, dn
 
Constructor Summary
LDAPSchema()
          This constructor was added to support default Serialization
LDAPSchema(LDAPEntry ent)
          Constructs an LDAPSchema object from attributes of an LDAPEntry.
 
Method Summary
private  void addElement(int schemaType, LDAPSchemaElement element)
          Adds the schema definition to the idList and nameList HashMaps.
 java.util.Enumeration getAttributeNames()
          Returns an enumeration of attribute names.
 LDAPAttributeSchema getAttributeSchema(java.lang.String name)
          Returns a particular attribute definition, or null if not found.
 java.util.Enumeration getAttributeSchemas()
          Returns an enumeration of attribute definitions.
 java.util.Enumeration getDITContentRuleNames()
          Returns an enumeration of DIT content rule names.
 LDAPDITContentRuleSchema getDITContentRuleSchema(java.lang.String name)
          Returns a particular DIT content rule definition, or null if not found.
 java.util.Enumeration getDITContentRuleSchemas()
          Returns an enumeration of DIT content rule definitions.
 java.util.Enumeration getDITStructureRuleNames()
          Returns an enumeration of DIT structure rule names.
 LDAPDITStructureRuleSchema getDITStructureRuleSchema(int ID)
          Returns a particular DIT structure rule definition, or null if not found.
 LDAPDITStructureRuleSchema getDITStructureRuleSchema(java.lang.String name)
          Returns a particular DIT structure rule definition, or null if not found.
 java.util.Enumeration getDITStructureRuleSchemas()
          Returns an enumeration of DIT structure rule definitions.
 java.util.Enumeration getMatchingRuleNames()
          Returns an enumeration of matching rule names.
 LDAPMatchingRuleSchema getMatchingRuleSchema(java.lang.String name)
          Returns a particular matching rule definition, or null if not found.
 java.util.Enumeration getMatchingRuleSchemas()
          Returns an enumeration of matching rule definitions.
 java.util.Enumeration getMatchingRuleUseNames()
          Returns an enumeration of matching rule use names.
 LDAPMatchingRuleUseSchema getMatchingRuleUseSchema(java.lang.String name)
          Returns a particular matching rule use definition, or null if not found.
 java.util.Enumeration getMatchingRuleUseSchemas()
          Returns an enumeration of matching rule use definitions.
 java.util.Enumeration getNameFormNames()
          Returns an enumeration of name form names.
 LDAPNameFormSchema getNameFormSchema(java.lang.String name)
          Returns a particular name form definition, or null if not found.
 java.util.Enumeration getNameFormSchemas()
          Returns an enumeration of name form definitions.
 java.util.Enumeration getObjectClassNames()
          Returns an enumeration of object class names.
 LDAPObjectClassSchema getObjectClassSchema(java.lang.String name)
          Returns a particular object class definition, or null if not found.
 java.util.Enumeration getObjectClassSchemas()
          Returns an enumeration of object class definitions.
private  LDAPSchemaElement getSchemaElement(int schemaType, java.lang.String key)
          This function abstracts retrieving LDAPSchemaElements from the local copy of schema in this LDAPSchema class.
 LDAPSyntaxSchema getSyntaxSchema(java.lang.String oid)
          Returns a particular syntax definition, or null if not found.
 java.util.Enumeration getSyntaxSchemas()
          Returns an enumeration of syntax definitions.
private  int getType(LDAPSchemaElement element)
          This helper function returns a number that represents the type of schema definition the element represents.
(package private) static LDAPXMLHandler getXMLHandler(java.lang.String tagname, LDAPXMLHandler parenthandler)
          This method return the LDAPHandler which handles the XML (DSML) tags for this class
static java.lang.Object readDSML(java.io.InputStream input)
          This method is used to deserialize the DSML encoded representation of this class.
 
Methods inherited from class com.novell.ldap.LDAPEntry
compareTo, getAttribute, getAttributeSet, getAttributeSet, getDN, newLine, readExternal, toString, writeDSML, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

idTable

private java.util.HashMap[] idTable
The idTable hash on the oid (or integer ID for DITStructureRule) and is used for retrieving enumerations


nameTable

private java.util.HashMap[] nameTable
The nameTable will hash on the names (if available). To insure case-insensibility, the Keys for this table will be a String cast to Uppercase.


schemaTypeNames

static final java.lang.String[] schemaTypeNames
The following lists the LDAP names of subschema attributes for schema elements (definitions):


ATTRIBUTE

static final int ATTRIBUTE
An index into the the arrays schemaTypeNames, idTable, and nameTable

See Also:
Constant Field Values

OBJECT_CLASS

static final int OBJECT_CLASS
An index into the the arrays schemaTypeNames, idTable, and nameTable

See Also:
Constant Field Values

SYNTAX

static final int SYNTAX
An index into the the arrays schemaTypeNames, idTable, and nameTable

See Also:
Constant Field Values

NAME_FORM

static final int NAME_FORM
An index into the the arrays schemaTypeNames, idTable, and nameTable

See Also:
Constant Field Values

DITCONTENT

static final int DITCONTENT
An index into the the arrays schemaTypeNames, idTable, and nameTable

See Also:
Constant Field Values

DITSTRUCTURE

static final int DITSTRUCTURE
An index into the the arrays schemaTypeNames, idTable, and nameTable

See Also:
Constant Field Values

MATCHING

static final int MATCHING
An index into the the arrays schemaTypeNames, idTable, and nameTable

See Also:
Constant Field Values

MATCHING_USE

static final int MATCHING_USE
An index into the the arrays schemaTypeNames, idTable, and nameTable

See Also:
Constant Field Values
Constructor Detail

LDAPSchema

public LDAPSchema()
This constructor was added to support default Serialization


LDAPSchema

public LDAPSchema(LDAPEntry ent)
Constructs an LDAPSchema object from attributes of an LDAPEntry.

The object is empty if the entry parameter contains no schema attributes. The recognized schema attributes are the following:


          "attributeTypes", "objectClasses", "ldapSyntaxes",
          "nameForms", "dITContentRules", "dITStructureRules",
          "matchingRules","matchingRuleUse"
 

Parameters:
ent - An LDAPEntry containing schema information.
Method Detail

addElement

private void addElement(int schemaType,
                        LDAPSchemaElement element)
Adds the schema definition to the idList and nameList HashMaps. This method is used by the methods fetchSchema and add. Note that the nameTable has all keys cast to Upper-case. This is so we can have a case-insensitive HashMap. The getXXX (String key) methods will also cast to uppercase.

Parameters:
schemaType - Type of schema definition, use one of the final integers defined at the top of this class: ATTRIBUTE, OBJECT_CLASS, SYNTAX, NAME_FORM, DITCONTENT, DITSTRUCTURE, MATCHING, MATCHING_USE
element - Schema element definition.

getSchemaElement

private LDAPSchemaElement getSchemaElement(int schemaType,
                                           java.lang.String key)
This function abstracts retrieving LDAPSchemaElements from the local copy of schema in this LDAPSchema class. This is used by getXXX(String name) functions.

Note that the nameTable has all keys cast to Upper-case. This is so we can have a case-insensitive HashMap. The getXXX (String key) methods will also cast to uppercase.

The first character of a NAME string can only be an alpha character (see section 4.1 of rfc2252) Thus if the first character is a digit we can conclude it is an OID. Note that this digit is ASCII only.

Parameters:
schemaType - Specifies which list is to be used in schema lookup.
key - The key can be either an OID or a name string.

getAttributeSchema

public LDAPAttributeSchema getAttributeSchema(java.lang.String name)
Returns a particular attribute definition, or null if not found.

Parameters:
name - Name or OID of the attribute for which a definition is to be returned.
Returns:
The attribute definition, or null if not found.

getDITContentRuleSchema

public LDAPDITContentRuleSchema getDITContentRuleSchema(java.lang.String name)
Returns a particular DIT content rule definition, or null if not found.

Parameters:
name - The name of the DIT content rule use for which a definition is to be returned.
Returns:
The DIT content rule definition, or null if not found.

getDITStructureRuleSchema

public LDAPDITStructureRuleSchema getDITStructureRuleSchema(java.lang.String name)
Returns a particular DIT structure rule definition, or null if not found.

Parameters:
name - The name of the DIT structure rule use for which a definition is to be returned.
Returns:
The DIT structure rule definition, or null if not found.

getDITStructureRuleSchema

public LDAPDITStructureRuleSchema getDITStructureRuleSchema(int ID)
Returns a particular DIT structure rule definition, or null if not found.

Parameters:
ID - The ID of the DIT structure rule use for which a definition is to be returned.
Returns:
The DIT structure rule definition, or null if not found.

getMatchingRuleSchema

public LDAPMatchingRuleSchema getMatchingRuleSchema(java.lang.String name)
Returns a particular matching rule definition, or null if not found.

Parameters:
name - The name of the matching rule for which a definition is to be returned.
Returns:
The matching rule definition, or null if not found.

getMatchingRuleUseSchema

public LDAPMatchingRuleUseSchema getMatchingRuleUseSchema(java.lang.String name)
Returns a particular matching rule use definition, or null if not found.

Parameters:
name - The name of the matching rule use for which a definition is to be returned.
Returns:
The matching rule use definition, or null if not found.

getNameFormSchema

public LDAPNameFormSchema getNameFormSchema(java.lang.String name)
Returns a particular name form definition, or null if not found.

Parameters:
name - The name of the name form for which a definition is to be returned.
Returns:
The name form definition, or null if not found.

getObjectClassSchema

public LDAPObjectClassSchema getObjectClassSchema(java.lang.String name)
Returns a particular object class definition, or null if not found.

Parameters:
name - The name or OID of the object class for which a definition is to be returned.
Returns:
The object class definition, or null if not found.

getSyntaxSchema

public LDAPSyntaxSchema getSyntaxSchema(java.lang.String oid)
Returns a particular syntax definition, or null if not found.

Parameters:
oid - The oid of the syntax for which a definition is to be returned.
Returns:
The syntax definition, or null if not found.

getAttributeSchemas

public java.util.Enumeration getAttributeSchemas()
Returns an enumeration of attribute definitions.

Returns:
An enumeration of attribute definitions.

getDITContentRuleSchemas

public java.util.Enumeration getDITContentRuleSchemas()
Returns an enumeration of DIT content rule definitions.

Returns:
An enumeration of DIT content rule definitions.

getDITStructureRuleSchemas

public java.util.Enumeration getDITStructureRuleSchemas()
Returns an enumeration of DIT structure rule definitions.

Returns:
An enumeration of DIT structure rule definitions.

getMatchingRuleSchemas

public java.util.Enumeration getMatchingRuleSchemas()
Returns an enumeration of matching rule definitions.

Returns:
An enumeration of matching rule definitions.

getMatchingRuleUseSchemas

public java.util.Enumeration getMatchingRuleUseSchemas()
Returns an enumeration of matching rule use definitions.

Returns:
An enumeration of matching rule use definitions.

getNameFormSchemas

public java.util.Enumeration getNameFormSchemas()
Returns an enumeration of name form definitions.

Returns:
An enumeration of name form definitions.

getObjectClassSchemas

public java.util.Enumeration getObjectClassSchemas()
Returns an enumeration of object class definitions.

Returns:
An enumeration of object class definitions.

getSyntaxSchemas

public java.util.Enumeration getSyntaxSchemas()
Returns an enumeration of syntax definitions.

Returns:
An enumeration of syntax definitions.

getAttributeNames

public java.util.Enumeration getAttributeNames()
Returns an enumeration of attribute names.

Returns:
An enumeration of attribute names.

getDITContentRuleNames

public java.util.Enumeration getDITContentRuleNames()
Returns an enumeration of DIT content rule names.

Returns:
An enumeration of DIT content rule names.

getDITStructureRuleNames

public java.util.Enumeration getDITStructureRuleNames()
Returns an enumeration of DIT structure rule names.

Returns:
An enumeration of DIT structure rule names.

getMatchingRuleNames

public java.util.Enumeration getMatchingRuleNames()
Returns an enumeration of matching rule names.

Returns:
An enumeration of matching rule names.

getMatchingRuleUseNames

public java.util.Enumeration getMatchingRuleUseNames()
Returns an enumeration of matching rule use names.

Returns:
An enumeration of matching rule use names.

getNameFormNames

public java.util.Enumeration getNameFormNames()
Returns an enumeration of name form names.

Returns:
An enumeration of name form names.

getObjectClassNames

public java.util.Enumeration getObjectClassNames()
Returns an enumeration of object class names.

Returns:
An enumeration of object class names.

getType

private int getType(LDAPSchemaElement element)
This helper function returns a number that represents the type of schema definition the element represents. The top of this file enumerates these types.

Parameters:
element - A class extending LDAPSchemaElement.
Returns:
a Number that identifies the type of schema element and will be one of the following: ATTRIBUTE, OBJECT_CLASS, SYNTAX, NAME_FORM, DITCONTENT, DITSTRUCTURE, MATCHING, MATCHING_USE

readDSML

public static java.lang.Object readDSML(java.io.InputStream input)
                                 throws java.io.IOException
This method is used to deserialize the DSML encoded representation of this class.

Parameters:
input - InputStream for the DSML formatted data.
Returns:
Deserialized form of this class.
Throws:
java.io.IOException - when serialization fails.

getXMLHandler

static LDAPXMLHandler getXMLHandler(java.lang.String tagname,
                                    LDAPXMLHandler parenthandler)
This method return the LDAPHandler which handles the XML (DSML) tags for this class

Parameters:
tagname - Name of the Root tag used to represent this class.
parenthandler - Parent LDAPXMLHandler for this tag.
Returns:
LDAPXMLHandler to handle this element.

All LDAP Classes
Internal LDAP Classes

Copyright ? 2002 Novell, Inc. All Rights Reserved.
Novell, Inc.
1800 South Novell Place
Provo, Ut 84606
Phone: (801) 861-5000