Package netscape.ldap

Class LDAPAttributeSet

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class LDAPAttributeSet
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    Represents a set of attributes (for example, the set of attributes in an entry).
    Version:
    1.0
    See Also:
    LDAPAttribute, Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(LDAPAttribute attr)
      Adds the specified attribute to this attribute set.
      java.lang.Object clone()  
      LDAPAttribute elementAt​(int index)
      Returns the attribute at the position specified by the index.
      LDAPAttribute getAttribute​(java.lang.String attrName)
      Returns a single attribute that exactly matches the specified attribute name.
      LDAPAttribute getAttribute​(java.lang.String attrName, java.lang.String lang)
      Returns the subtype that matches the attribute name specified by attrName and the language specificaton identified by lang.
      java.util.Enumeration<LDAPAttribute> getAttributes()
      Returns an enumeration of the attributes in this attribute set.
      LDAPAttributeSet getSubset​(java.lang.String subtype)
      Creates a new attribute set containing only the attributes that have the specified subtypes.
      void remove​(java.lang.String name)
      Removes the specified attribute from the set.
      void removeElementAt​(int index)
      Removes the attribute at the position specified by the index.
      int size()
      Returns the number of attributes in this set.
      java.lang.String toString()
      Retrieves the string representation of all attributes in the attribute set.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • 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 Detail

      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object
      • getAttributes

        public java.util.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​(java.lang.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:
        LDAPAttribute, getAttribute(java.lang.String), LDAPEntry.getAttributeSet()
      • getAttribute

        public LDAPAttribute getAttribute​(java.lang.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:
        LDAPAttribute
      • getAttribute

        public LDAPAttribute getAttribute​(java.lang.String attrName,
                                          java.lang.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:
        LDAPAttribute
      • 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​(java.lang.String name)
        Removes the specified attribute from the set.
        Parameters:
        name - name of the attribute to remove
      • toString

        public java.lang.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 java.lang.Object
        Returns:
        string representation of all attributes in the set.