src/java.sql.rowset/share/classes/javax/sql/rowset/spi/SyncProviderException.java
author darcy
Wed, 25 Sep 2019 09:37:18 -0700
changeset 58338 faf791c5a710
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231442: Suppress warnings on non-serializable instance fields in java.sql.* modules Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58338
faf791c5a710 8231442: Suppress warnings on non-serializable instance fields in java.sql.* modules
darcy
parents: 47216
diff changeset
     2
 * Copyright (c) 2003, 2019, 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.sql.rowset.spi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.sql.SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.sql.rowset.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Indicates an error with the <code>SyncProvider</code> mechanism. This exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * is created by a <code>SyncProvider</code> abstract class extension if it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * encounters violations in reading from or writing to the originating data source.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * If it is implemented to do so, the <code>SyncProvider</code> object may also create a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <code>SyncResolver</code> object and either initialize the <code>SyncProviderException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * object with it at construction time or set it with the <code>SyncProvider</code> object at
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * a later time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * The method <code>acceptChanges</code> will throw this exception after the writer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * has finished checking for conflicts and has found one or more conflicts. An
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * application may catch a <code>SyncProviderException</code> object and call its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <code>getSyncResolver</code> method to get its <code>SyncResolver</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * See the code fragment in the interface comment for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <a href="SyncResolver.html"><code>SyncResolver</code></a> for an example.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * This <code>SyncResolver</code> object will mirror the <code>RowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * object that generated the exception, except that it will contain only the values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * from the data source that are in conflict.  All other values in the <code>SyncResolver</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * object will be <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * The <code>SyncResolver</code> object may be used to examine and resolve
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * each conflict in a row and then go to the next row with a conflict to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * repeat the procedure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * A <code>SyncProviderException</code> object may or may not contain a description of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * condition causing the exception.  The inherited method <code>getMessage</code> may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * called to retrieve the description if there is one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * @author Jonathan Bruce
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @see javax.sql.rowset.spi.SyncFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @see javax.sql.rowset.spi.SyncResolver
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @see javax.sql.rowset.spi.SyncFactoryException
24968
3308660aa3f2 8046389: Add missing @since tag under javax.sql.**
henryjen
parents: 5506
diff changeset
    64
 * @since 1.5
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
public class SyncProviderException extends java.sql.SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * The instance of <code>javax.sql.rowset.spi.SyncResolver</code> that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * this <code>SyncProviderException</code> object will return when its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * <code>getSyncResolver</code> method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
58338
faf791c5a710 8231442: Suppress warnings on non-serializable instance fields in java.sql.* modules
darcy
parents: 47216
diff changeset
    73
     @SuppressWarnings("serial") // Not statically typed as Serializable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     private SyncResolver syncResolver = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Creates a new <code>SyncProviderException</code> object without a detail message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public SyncProviderException() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Constructs a <code>SyncProviderException</code> object with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * detail message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param msg the detail message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public SyncProviderException(String msg)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        super(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * Constructs a <code>SyncProviderException</code> object with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * <code>SyncResolver</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * @param syncResolver the <code>SyncResolver</code> instance used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *     to process the synchronization conflicts
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @throws IllegalArgumentException if the <code>SyncResolver</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *     is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public SyncProviderException(SyncResolver syncResolver)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        if (syncResolver == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            throw new IllegalArgumentException("Cannot instantiate a SyncProviderException " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                "with a null SyncResolver object");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            this.syncResolver = syncResolver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Retrieves the <code>SyncResolver</code> object that has been set for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * this <code>SyncProviderException</code> object, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * if none has been set, an instance of the default <code>SyncResolver</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * implementation included in the reference implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * If a <code>SyncProviderException</code> object is thrown, an application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * may use this method to generate a <code>SyncResolver</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * with which to resolve the conflict or conflicts that caused the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * exception to be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @return the <code>SyncResolver</code> object set for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *     <code>SyncProviderException</code> object or, if none has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *     been set, an instance of the default <code>SyncResolver</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     *     implementation. In addition, the default <code>SyncResolver</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *     implementation is also returned if the <code>SyncResolver()</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *     <code>SyncResolver(String)</code> constructors are used to instantiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *     the <code>SyncResolver</code> instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    public SyncResolver getSyncResolver() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        if (syncResolver != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            return syncResolver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
              syncResolver = new com.sun.rowset.internal.SyncResolverImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            } catch (SQLException sqle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            return syncResolver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Sets the <code>SyncResolver</code> object for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * <code>SyncProviderException</code> object to the one supplied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * If the argument supplied is <code>null</code>, a call to the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <code>getSyncResolver</code> will return the default reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * implementation of the <code>SyncResolver</code> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @param syncResolver the <code>SyncResolver</code> object to be set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *     cannot be <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @throws IllegalArgumentException if the <code>SyncResolver</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *     is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @see #getSyncResolver
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public void setSyncResolver(SyncResolver syncResolver) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        if (syncResolver == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            throw new IllegalArgumentException("Cannot set a null SyncResolver " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                "object");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            this.syncResolver = syncResolver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    static final long serialVersionUID = -939908523620640692L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
}