Class ObjectClasses

java.lang.Object
com.isode.dsapi.ObjectClasses

public class ObjectClasses extends Object
Representation of a set of object classes.

When constructed, the list of object-classes provided is expanded to include all the super-classes. This means that it is possible to construct the set from simply "inetOrgPerson", for instance, without mentioning all the superclasses.

Note that it is not possible to query isAllowed() or isRequired() per object-class, because normally it is not that useful to do that, because each object-class depends on others and a particular attribute may be included by more than one of them.

The list of objectclasses built up internally is sorted into a kind of hierarchical order, with superclasses always before subclasses. This is repeatable (i.e. will always be the same for the same schema definition and list of objectclasses provided). The order is top-down, aiming for the lead structural objectclass first and then for each of the lead auxiliary objectclasses. Note that this ordering may be tweaked -- it is designed more to make sense to a human, rather than for automated tests.

  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Base constructor.
     
    Construct from the values of an Attribute.
     
    Construct from an array of AttributeValues containing object-class names.
     
    Construct from a space-separated list of object-class names.
     
    Construct from an array of object-class names.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    Fetch the alternative name of an objectclass, if it has one.
    Get the complete list of AttributeTypes that would be allowed within an Entry using these object-classes.
    Get the complete list of attribute names that would be allowed within an Entry using these object-classes.
    static String[]
    getCompletions(String partial_name)
    Return an array containing all the objectclass names that start with the given string.
    int
    Determine the number of object-class names stored.
    int
    getDepth(int ii)
    Determine the depth of an objectclass in the class hierarchy.
    static String
    getOID(String name)
    Fetch the OID of an objectclass, if it is known to the schema.
    int
    getParent(int ii, int n)
    Determine the index of the 'n'th parent class of the object-class at the given index.
    Get the complete list of AttributeTypes that would be required within an Entry using these object-classes.
    Get the complete list of attribute names that would be required within an Entry using these object-classes.
    Get the list of object-class names as a space-separated String.
    getString(int ii)
    Get the name of the object-class at the given index.
    Get the list of object-class names as a String[].
    static String[]
    Get a list of all the immediate subclasses of the given objectclass - that is, those objectclasses which list the given objectclass as a parent.
    int
    Find the index of a specific objectclass in the internal array
    boolean
    isAbstract(int ii)
    Determine whether the object-class at the given index is an abstract class.
    boolean
    Determine whether a particular AttributeType would be allowed within an Entry which had this set of objectclasses.
    boolean
    Determine whether a particular type of attribute would be allowed within an Entry which had this set of objectclasses.
    boolean
    isAuxiliary(int ii)
    Determine whether the object-class at the given index is an auxiliary class
    boolean
    Determine whether an Entry with these objectclasses is an extensible object.
    boolean
    Determine whether the object-class at the given index is a 'lead' class in the set.
    boolean
    Determine whether a particular AttributeType would be required within an Entry which has this set of objectclasses (in other words, whether the type is compulsory).
    boolean
    Determine whether a particular type of attribute would be required within an Entry which had this set of objectclasses (in other words, whether the type is compulsory).
    boolean
    isStructural(int ii)
    Determine whether the object-class at the given index is a structural class
    boolean
    isSubClass(int ii, int jj)
    Determine whether one object-class in the set is a subclass of another in the same set.
    Return a string representation of the contained object-classes, showing flag information.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ObjectClasses

      protected ObjectClasses()
      Base constructor.
    • ObjectClasses

      public ObjectClasses(String list) throws BadValueException
      Construct from a space-separated list of object-class names.
      Parameters:
      list - a space-separated list of objectclasses, for example, "organization" or "person pkiuser"
      Throws:
      BadValueException - if any object-class name is not known.
    • ObjectClasses

      public ObjectClasses(String[] list) throws BadValueException
      Construct from an array of object-class names.
      Parameters:
      list - an array of Strings each containing a single objectclass name, e.g. "person"
      Throws:
      BadValueException - if any object-class name is not known.
    • ObjectClasses

      public ObjectClasses(AttributeValue[] list) throws BadValueException
      Construct from an array of AttributeValues containing object-class names. The AttributeType of each value is not significant; only the values are used.
      Parameters:
      list - an array of AttributeValue objects, representing values such as objectclass=person
      Throws:
      BadValueException - if any object-class name is not known.
    • ObjectClasses

      public ObjectClasses(Attribute attr) throws BadValueException
      Construct from the values of an Attribute. The AttributeType is not significant; only the values are used.
      Parameters:
      attr - an Attribute containing values from which this object will be created, for example objectclass=person,pkiuser
      Throws:
      BadValueException - if any object-class name is not known.
  • Method Details

    • getStrings

      public String[] getStrings()
      Get the list of object-class names as a String[].
      Returns:
      an array of Strings, for example: {"top", "person", "organizationalPerson", "inetorgperson"}
    • indexOf

      public int indexOf(String name)
      Find the index of a specific objectclass in the internal array
      Parameters:
      name - object class to search for, e.g. "person"
      Returns:
      index of objectclass, or -1 if not found
    • getString

      public String getString()
      Get the list of object-class names as a space-separated String.
      Returns:
      a String containing all the object classes, e.g. "top person organizationalPerson inetorgperson"
    • isAllowed

      public boolean isAllowed(AttributeType type)
      Determine whether a particular AttributeType would be allowed within an Entry which had this set of objectclasses.
      Parameters:
      type - an AttributeType
      Returns:
      true if type is allowed, false otherwise.
    • isAllowed

      public boolean isAllowed(String type)
      Determine whether a particular type of attribute would be allowed within an Entry which had this set of objectclasses.
      Parameters:
      type - a String representation of an AttributeType, e.g. "sn"
      Returns:
      true if type is allowed, false otherwise.
    • isRequired

      public boolean isRequired(AttributeType type)
      Determine whether a particular AttributeType would be required within an Entry which has this set of objectclasses (in other words, whether the type is compulsory).
      Parameters:
      type - an AttributeType
      Returns:
      true if type is required, false otherwise.
    • isRequired

      public boolean isRequired(String type)
      Determine whether a particular type of attribute would be required within an Entry which had this set of objectclasses (in other words, whether the type is compulsory).
      Parameters:
      type - a String representation of an AttributeType, e.g. "sn"
      Returns:
      true if type is required, false otherwise.
    • getAllowed

      public AttributeType[] getAllowed()
      Get the complete list of AttributeTypes that would be allowed within an Entry using these object-classes.
      Returns:
      an array of AttributeType objects.
    • getRequired

      public AttributeType[] getRequired()
      Get the complete list of AttributeTypes that would be required within an Entry using these object-classes.
      Returns:
      an array of AttributeType objects.
    • getAllowedNames

      public String[] getAllowedNames()
      Get the complete list of attribute names that would be allowed within an Entry using these object-classes. Note that this does not include aliases. Use AttributeType.getAlias(String) to switch to/from alias names.
      Returns:
      an array of Strings, e.g. {"c", "description", "objectClass", "searchGuide"}
    • getRequiredNames

      public String[] getRequiredNames()
      Get the complete list of attribute names that would be required within an Entry using these object-classes. Note that this does not include aliases. Use AttributeType.getAlias() to switch to/from alias names.
      Returns:
      an array of Strings, e.g. {"c", "objectClass"}
    • getCount

      public int getCount()
      Determine the number of object-class names stored. This may be more than the number of object-classes provided to the contructor, as all superclasses will have been filled in.
      Returns:
      the number of objectclass names stored.
    • getString

      public String getString(int ii)
      Get the name of the object-class at the given index.
      Parameters:
      ii - index, which should be in the range zero to (getCount()-1).
      Returns:
      the name of the objectclass at index ii.
    • isAuxiliary

      public boolean isAuxiliary(int ii)
      Determine whether the object-class at the given index is an auxiliary class
      Parameters:
      ii - index, which should be in the range zero to (getCount()-1).
      Returns:
      true if the objectclass is auxiliary, false otherwise.
    • isStructural

      public boolean isStructural(int ii)
      Determine whether the object-class at the given index is a structural class
      Parameters:
      ii - index, which should be in the range zero to (getCount()-1).
      Returns:
      true if the objectclass is structural, false otherwise.
    • isAbstract

      public boolean isAbstract(int ii)
      Determine whether the object-class at the given index is an abstract class.
      Parameters:
      ii - index, which should be in the range zero to (getCount()-1).
      Returns:
      true if the objectclass is abstract, false otherwise.
    • isLeadObjectClass

      public boolean isLeadObjectClass(int ii)
      Determine whether the object-class at the given index is a 'lead' class in the set. Lead classes are those that don't have sub-classes present in the set, i.e. those that make up the minimum set of object-classes required to define the set.
      Parameters:
      ii - index, which should be in the range zero to (getCount()-1).
      Returns:
      true if the objectclass is a 'lead' objectclass; false otherwise.
    • getParent

      public int getParent(int ii, int n)
      Determine the index of the 'n'th parent class of the object-class at the given index. If the objectclass has no parents at all (for example, "top"), the method returns -1.
      Parameters:
      ii - index of the objectclass of interest, which should be in the range zero to (getCount()-1).
      n - value determining which parent is required, which should be in the range 0..(N-1) where N is the total number of parents.
      Returns:
      -1 if there is no n'th parent (i.e. n >=N).
    • isSubClass

      public boolean isSubClass(int ii, int jj)
      Determine whether one object-class in the set is a subclass of another in the same set.
      Parameters:
      ii - index of first objectclass, which should be in the range zero to (getCount()-1).
      jj - index of second objectclass, which should be in the range zero to (getCount()-1).
      Returns:
      true if the objectclass at index ii is a subclass of that at index jj; false otherwise.
    • getDepth

      public int getDepth(int ii)
      Determine the depth of an objectclass in the class hierarchy. For example, typically person has a depth of 2; organizationalPerson, which subclasses person, has a depth of 3, and inetorgperson, which subclasses organizationalPerson a depth of 4
      Parameters:
      ii - index of the objectclass that is of interest, which should be in the range zero to (getCount()-1).
      Returns:
      the depth of the specified objectclass, where 'top' counts as level 1.
    • isExtensibleObject

      public boolean isExtensibleObject()
      Determine whether an Entry with these objectclasses is an extensible object. An extensible object is one where all attribute types are permitted within the entry, not just the ones on the 'allowed' list. This is indicated by the presence of the 'extensibleObject' objectclass.
      Returns:
      true if this is represents an extensibleobject; false otherwise.
    • toString

      public String toString()
      Return a string representation of the contained object-classes, showing flag information. An asterisk indicates lead object-classes, (a) indicates abstract, (A) for auxiliary, (S) for structural, (o) for obsolete.
      Overrides:
      toString in class Object
      Returns:
      a String, useful for debugging purposes.
    • getCompletions

      public static String[] getCompletions(String partial_name)
      Return an array containing all the objectclass names that start with the given string. This is intended for getting a list of all possible objectclasses (passing ""), or doing objectclass-name auto-completion (passing user's current input).
      Parameters:
      partial_name - Initial part of the objectclass name to match, for example "organi"
      Returns:
      String[] of the objectclasses, for example {"organization", "organizationalUnit", "organizationalPerson", "organizationalRole"}. If no objectclass names match partial_name, then an array with zero elements will be returned.
    • getSubClasses

      public static String[] getSubClasses(String name)
      Get a list of all the immediate subclasses of the given objectclass - that is, those objectclasses which list the given objectclass as a parent.
      Parameters:
      name - Objectclass to check for subclasses, for example "person".
      Returns:
      String[] of objectclass-names, for example {"organizationalPerson", "residentialPerson", "newPilotPerson"}. If there are no subclasses of name, then an array with zero elements will be returned.
    • getAlias

      public static String getAlias(String name)
      Fetch the alternative name of an objectclass, if it has one. This converts the short name to the long name, or vice versa. It also converts the OID to the first name listed.
      Parameters:
      name - Objectclass name to check for alias
      Returns:
      Alternative objectclass-type name, or 'null' if there isn't an alias, or for any other problem
    • getOID

      public static String getOID(String name)
      Fetch the OID of an objectclass, if it is known to the schema.
      Parameters:
      name - Objectclass name to check
      Returns:
      OID if available, or otherwise 'null'
      Since:
      14.4