1. /*
  2. * @(#)Attributes.java 1.7 01/02/09
  3. *
  4. * Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.naming.directory;
  11. import java.util.Hashtable;
  12. import java.util.Enumeration;
  13. import javax.naming.NamingException;
  14. import javax.naming.NamingEnumeration;
  15. /**
  16. * This interface represents a collection of attributes.
  17. *<p>
  18. * In a directory, named objects can have associated with them
  19. * attributes. The Attributes interface represents a collection of attributes.
  20. * For example, you can request from the directory the attributes
  21. * associated with an object. Those attributes are returned in
  22. * an object that implements the Attributes interface.
  23. *<p>
  24. * Attributes in an object that implements the Attributes interface are
  25. * unordered. The object can have zero or more attributes.
  26. * Attributes is either case-sensitive or case-insensitive (case-ignore).
  27. * This property is determined at the time the Attributes object is
  28. * created. (see BasicAttributes constructor for example).
  29. * In a case-insensitive Attributes, the case of its attribute identifiers
  30. * is ignored when searching for an attribute, or adding attributes.
  31. * In a case-sensitive Attributes, the case is significant.
  32. *<p>
  33. * Note that updates to Attributes (such as adding or removing an attribute)
  34. * do not affect the corresponding representation in the directory.
  35. * Updates to the directory can only be effected
  36. * using operations in the DirContext interface.
  37. *
  38. * @author Rosanna Lee
  39. * @author Scott Seligman
  40. * @version 1.7 01/02/09
  41. *
  42. * @see DirContext#getAttributes
  43. * @see DirContext#modifyAttributes
  44. * @see DirContext#bind
  45. * @see DirContext#rebind
  46. * @see DirContext#createSubcontext
  47. * @see DirContext#search
  48. * @see BasicAttributes
  49. * @since 1.3
  50. */
  51. public interface Attributes extends Cloneable, java.io.Serializable {
  52. /**
  53. * Determines whether the attribute set ignores the case of
  54. * attribute identifiers when retrieving or adding attributes.
  55. * @return true if case is ignored; false otherwise.
  56. */
  57. boolean isCaseIgnored();
  58. /**
  59. * Retrieves the number of attributes in the attribute set.
  60. *
  61. * @return The nonnegative number of attributes in this attribute set.
  62. */
  63. int size();
  64. /**
  65. * Retrieves the attribute with the given attribute id from the
  66. * attribute set.
  67. *
  68. * @param attrID The non-null id of the attribute to retrieve.
  69. * If this attribute set ignores the character
  70. * case of its attribute ids, the case of attrID
  71. * is ignored.
  72. * @return The attribute identified by attrID; null if not found.
  73. * @see #put
  74. * @see #remove
  75. */
  76. Attribute get(String attrID);
  77. /**
  78. * Retrieves an enumeration of the attributes in the attribute set.
  79. * The effects of updates to this attribute set on this enumeration
  80. * are undefined.
  81. *
  82. * @return A non-null enumeration of the attributes in this attribute set.
  83. * Each element of the enumeration is of class <tt>Attribute</tt>.
  84. * If attribute set has zero attributes, an empty enumeration
  85. * is returned.
  86. */
  87. NamingEnumeration getAll();
  88. /**
  89. * Retrieves an enumeration of the ids of the attributes in the
  90. * attribute set.
  91. * The effects of updates to this attribute set on this enumeration
  92. * are undefined.
  93. *
  94. * @return A non-null enumeration of the attributes' ids in
  95. * this attribute set. Each element of the enumeration is
  96. * of class String.
  97. * If attribute set has zero attributes, an empty enumeration
  98. * is returned.
  99. */
  100. NamingEnumeration getIDs();
  101. /**
  102. * Adds a new attribute to the attribute set.
  103. *
  104. * @param attrID non-null The id of the attribute to add.
  105. * If the attribute set ignores the character
  106. * case of its attribute ids, the case of attrID
  107. * is ignored.
  108. * @param val The possibly null value of the attribute to add.
  109. * If null, the attribute does not have any values.
  110. * @return The Attribute with attrID that was previous in this attribute set;
  111. * null if no such attribute existed.
  112. * @see #remove
  113. */
  114. Attribute put(String attrID, Object val);
  115. /**
  116. * Adds a new attribute to the attribute set.
  117. *
  118. * @param attr The non-null attribute to add.
  119. * If the attribute set ignores the character
  120. * case of its attribute ids, the case of
  121. * attr's identifier is ignored.
  122. * @return The Attribute with the same ID as attr that was previous
  123. * in this attribute set;
  124. * null if no such attribute existed.
  125. * @see #remove
  126. */
  127. Attribute put(Attribute attr);
  128. /**
  129. * Removes the attribute with the attribute id 'attrID' from
  130. * the attribute set. If the attribute does not exist, ignore.
  131. *
  132. * @param attrID The non-null id of the attribute to remove.
  133. * If the attribute set ignores the character
  134. * case of its attribute ids, the case of
  135. * attrID is ignored.
  136. * @return The Attribute with the same ID as attrID that was previous
  137. * in the attribute set;
  138. * null if no such attribute existed.
  139. */
  140. Attribute remove(String attrID);
  141. /**
  142. * Makes a copy of the attribute set.
  143. * The new set contains the same attributes as the original set:
  144. * the attributes are not themselves cloned.
  145. * Changes to the copy will not affect the original and vice versa.
  146. *
  147. * @return A non-null copy of this attribute set.
  148. */
  149. Object clone();
  150. /**
  151. * Use serialVersionUID from JNDI 1.1.1 for interoperability
  152. */
  153. // static final long serialVersionUID = -7247874645443605347L;
  154. }