Package netscape.ldap

Class LDAPAttributeSet

java.lang.Object
netscape.ldap.LDAPAttributeSet
All Implemented Interfaces:
Serializable, Cloneable

public class LDAPAttributeSet extends Object implements Cloneable, Serializable
Represents a set of attributes (for example, the set of attributes in an entry).
Version:
1.0
See Also:
  • Constructor Details

    • LDAPAttributeSet

      public LDAPAttributeSet()
      Constructs a new set of attributes. This set is initially empty.
    • LDAPAttributeSet

      public LDAPAttributeSet(LDAPAttribute[] attrs)
      Constructs an attribute set.
      Parameters:
      attrs - the list of attributes
  • Method Details

    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • getAttributes

      public Enumeration<LDAPAttribute> getAttributes()
      Returns an enumeration of the attributes in this attribute set.
      Returns:
      enumeration of the attributes in this set.
    • getSubset

      public LDAPAttributeSet getSubset(String subtype)
      Creates a new attribute set containing only the attributes that have the specified subtypes.

      For example, suppose an attribute set contains the following attributes:

       cn
       cn;lang-ja
       sn;phonetic;lang-ja
       sn;lang-us
       
      If you call the getSubset method and pass lang-ja as the argument, the method returns an attribute set containing the following attributes:

       cn;lang-ja
       sn;phonetic;lang-ja
       
      Parameters:
      subtype - semi-colon delimited list of subtypes to find within attribute names. For example:
           "lang-ja"        // Only Japanese language subtypes
           "binary"         // Only binary subtypes
           "binary;lang-ja" // Only Japanese language subtypes
                               which also are binary
       
      Returns:
      attribute set containing the attributes that have the specified subtypes.
      See Also:
    • getAttribute

      public LDAPAttribute getAttribute(String attrName)
      Returns a single attribute that exactly matches the specified attribute name.
      Parameters:
      attrName - name of attribute to return For example:
           "cn"            // Only a non-subtyped version of cn
           "cn;lang-ja"    // Only a Japanese version of cn
      
      Returns:
      attribute that has exactly the same name, or null (if no attribute in the set matches the specified name).
      See Also:
    • getAttribute

      public LDAPAttribute getAttribute(String attrName, String lang)
      Returns the subtype that matches the attribute name specified by attrName and the language specificaton identified by lang.

      If no attribute in the set has the specified name and subtype, the method returns null. Attributes containing subtypes other than lang (for example, cn;binary) are returned only if they contain the specified lang subtype and if the set contains no attribute having only the lang subtype. (For example, getAttribute( "cn", "lang-ja" ) returns cn;lang-ja;phonetic only if the cn;lang-ja attribute does not exist.)

      If null is specified for the lang argument, calling this method is the same as calling the getAttribute(attrName) method.

      For example, suppose an entry contains only the following attributes:

      • cn;lang-en
      • cn;lang-ja-JP-kanji
      • sn

      Calling the following methods will return the following values:

      • getAttribute( "cn" ) returns null.
      • getAttribute( "sn" ) returns the "sn" attribute.
      • getAttribute( "cn", "lang-en-us" ) returns the "cn;lang-en" attribute.
      • getAttribute( "cn", "lang-en" ) returns the "cn;lang-en" attribute.
      • getAttribute( "cn", "lang-ja" ) returns null.
      • getAttribute( "sn", "lang-en" ) returns the "sn" attribute.

      Parameters:
      attrName - name of attribute to find in the entry
      lang - a language specification
      Returns:
      the attribute that matches the base name and that best matches any specified language subtype.
      See Also:
    • elementAt

      public LDAPAttribute elementAt(int index)
      Returns the attribute at the position specified by the index. For example, if you specify the index 0, the method returns the first attribute in the set. The index is 0-based.
      Parameters:
      index - index of the attribute to obtain
      Returns:
      attribute at the position specified by the index.
    • removeElementAt

      public void removeElementAt(int index)
      Removes the attribute at the position specified by the index. For example, if you specify the index 0, the method removes the first attribute in the set. The index is 0-based.
      Parameters:
      index - index of the attribute to remove
    • size

      public int size()
      Returns the number of attributes in this set.
      Returns:
      number of attributes in this attribute set.
    • add

      public void add(LDAPAttribute attr)
      Adds the specified attribute to this attribute set.
      Parameters:
      attr - attribute to add to this set
    • remove

      public void remove(String name)
      Removes the specified attribute from the set.
      Parameters:
      name - name of the attribute to remove
    • toString

      public String toString()
      Retrieves the string representation of all attributes in the attribute set. For example:
       LDAPAttributeSet: LDAPAttribute {type='cn', values='Barbara Jensen,Babs
       Jensen'}LDAPAttribute {type='sn', values='Jensen'}LDAPAttribute {type='
       givenname', values='Barbara'}LDAPAttribute {type='objectclass', values=
       'top,person,organizationalPerson,inetOrgPerson'}LDAPAttribute {type='ou',
       values='Product Development,People'}
       
      Overrides:
      toString in class Object
      Returns:
      string representation of all attributes in the set.