src/java.naming/share/classes/javax/naming/directory/AttributeModificationException.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.naming.directory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.naming.NamingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
  * This exception is thrown when an attempt is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
  * made to add, or remove, or modify an attribute, its identifier,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
  * or its values that conflicts with the attribute's (schema) definition
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  * or the attribute's state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  * It is thrown in response to DirContext.modifyAttributes().
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  * It contains a list of modifications that have not been performed, in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
  * order that they were supplied to modifyAttributes().
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  * If the list is null, none of the modifications were performed successfully.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  * An AttributeModificationException instance is not synchronized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  * against concurrent multithreaded access. Multiple threads trying
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  * to access and modify a single AttributeModification instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  * should lock the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  * @author Scott Seligman
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  * @see DirContext#modifyAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  * The serialized form of an AttributeModificationException object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  * consists of the serialized fields of its NamingException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  * superclass, followed by an array of ModificationItem objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
public class AttributeModificationException extends NamingException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Contains the possibly null list of unexecuted modifications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private ModificationItem[] unexecs = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Constructs a new instance of AttributeModificationException using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * an explanation. All other fields are set to null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @param   explanation     Possibly null additional detail about this exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * If null, this exception has no detail message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @see java.lang.Throwable#getMessage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public AttributeModificationException(String explanation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        super(explanation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
      * Constructs a new instance of AttributeModificationException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
      * All fields are set to null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public AttributeModificationException() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
      * Sets the unexecuted modification list to be e.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
      * Items in the list must appear in the same order in which they were
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
      * originally supplied in DirContext.modifyAttributes().
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
      * The first item in the list is the first one that was not executed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
      * If this list is null, none of the operations originally submitted
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
      * to modifyAttributes() were executed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
      * @param e        The possibly null list of unexecuted modifications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
      * @see #getUnexecutedModifications
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    public void setUnexecutedModifications(ModificationItem[] e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        unexecs = e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
      * Retrieves the unexecuted modification list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
      * Items in the list appear in the same order in which they were
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
      * originally supplied in DirContext.modifyAttributes().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      * The first item in the list is the first one that was not executed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
      * If this list is null, none of the operations originally submitted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
      * to modifyAttributes() were executed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
      * @return The possibly null unexecuted modification list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
      * @see #setUnexecutedModifications
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    public ModificationItem[] getUnexecutedModifications() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        return unexecs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      * The string representation of this exception consists of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
      * information about where the error occurred, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
      * the first unexecuted modification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
      * This string is meant for debugging and not mean to be interpreted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
      * programmatically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
      * @return The non-null string representation of this exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        String orig = super.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if (unexecs != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            orig += ("First unexecuted modification: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                     unexecs[0].toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return orig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * Use serialVersionUID from JNDI 1.1.1 for interoperability
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private static final long serialVersionUID = 8060676069678710186L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
}