1. /*
  2. * @(#)AttributeModificationException.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 javax.naming.NamingException;
  12. /**
  13. * This exception is thrown when an attempt is
  14. * made to add, or remove, or modify an attribute, its identifier,
  15. * or its values that conflicts with the attribute's (schema) definition
  16. * or the attribute's state.
  17. * It is thrown in response to DirContext.modifyAttributes().
  18. * It contains a list of modifications that have not been performed, in the
  19. * order that they were supplied to modifyAttributes().
  20. * If the list is null, none of the modifications were performed successfully.
  21. *<p>
  22. * An AttributeModificationException instance is not synchronized
  23. * against concurrent multithreaded access. Multiple threads trying
  24. * to access and modify a single AttributeModification instance
  25. * should lock the object.
  26. *
  27. * @author Rosanna Lee
  28. * @author Scott Seligman
  29. * @version 1.7 01/02/09
  30. *
  31. * @see DirContext#modifyAttributes
  32. * @since 1.3
  33. */
  34. /*
  35. *<p>
  36. * The serialized form of an AttributeModificationException object
  37. * consists of the serialized fields of its NamingException
  38. * superclass, followed by an array of ModificationItem objects.
  39. *
  40. */
  41. public class AttributeModificationException extends NamingException {
  42. /**
  43. * Contains the possibly null list of unexecuted modifications.
  44. * @serial
  45. */
  46. private ModificationItem[] unexecs = null;
  47. /**
  48. * Constructs a new instance of AttributeModificationException using
  49. * an explanation. All other fields are set to null.
  50. *
  51. * @param explanation Possibly null additional detail about this exception.
  52. * If null, this exception has no detail message.
  53. * @see java.lang.Throwable#getMessage
  54. */
  55. public AttributeModificationException(String explanation) {
  56. super(explanation);
  57. }
  58. /**
  59. * Constructs a new instance of AttributeModificationException.
  60. * All fields are set to null.
  61. */
  62. public AttributeModificationException() {
  63. super();
  64. }
  65. /**
  66. * Sets the unexecuted modification list to be e.
  67. * Items in the list must appear in the same order in which they were
  68. * originally supplied in DirContext.modifyAttributes().
  69. * The first item in the list is the first one that was not executed.
  70. * If this list is null, none of the operations originally submitted
  71. * to modifyAttributes() were executed.
  72. * @param e The possibly null list of unexecuted modifications.
  73. * @see #getUnexecutedModifications
  74. */
  75. public void setUnexecutedModifications(ModificationItem[] e) {
  76. unexecs = e;
  77. }
  78. /**
  79. * Retrieves the unexecuted modification list.
  80. * Items in the list appear in the same order in which they were
  81. * originally supplied in DirContext.modifyAttributes().
  82. * The first item in the list is the first one that was not executed.
  83. * If this list is null, none of the operations originally submitted
  84. * to modifyAttributes() were executed.
  85. * @return The possibly null unexecuted modification list.
  86. * @see #setUnexecutedModifications
  87. */
  88. public ModificationItem[] getUnexecutedModifications() {
  89. return unexecs;
  90. }
  91. /**
  92. * The string representation of this exception consists of
  93. * information about where the error occurred, and
  94. * the first unexecuted modification.
  95. * This string is meant for debugging and not mean to be interpreted
  96. * programmatically.
  97. * @return The non-null string representation of this exception.
  98. */
  99. public String toString() {
  100. String orig = super.toString();
  101. if (unexecs != null) {
  102. orig += ("First unexecuted modification: " +
  103. unexecs[0].toString());
  104. }
  105. return orig;
  106. }
  107. /**
  108. * Use serialVersionUID from JNDI 1.1.1 for interoperability
  109. */
  110. private static final long serialVersionUID = 8060676069678710186L;
  111. }