0N/A/*
2362N/A * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.sql.rowset.spi;
0N/A
0N/Aimport java.sql.SQLException;
0N/Aimport javax.sql.rowset.*;
0N/A
0N/A/**
0N/A * Indicates an error with the <code>SyncProvider</code> mechanism. This exception
0N/A * is created by a <code>SyncProvider</code> abstract class extension if it
0N/A * encounters violations in reading from or writing to the originating data source.
0N/A * <P>
0N/A * If it is implemented to do so, the <code>SyncProvider</code> object may also create a
0N/A * <code>SyncResolver</code> object and either initialize the <code>SyncProviderException</code>
0N/A * object with it at construction time or set it with the <code>SyncProvider</code> object at
0N/A * a later time.
0N/A * <P>
0N/A * The method <code>acceptChanges</code> will throw this exception after the writer
0N/A * has finished checking for conflicts and has found one or more conflicts. An
0N/A * application may catch a <code>SyncProviderException</code> object and call its
0N/A * <code>getSyncResolver</code> method to get its <code>SyncResolver</code> object.
0N/A * See the code fragment in the interface comment for
0N/A * <a href="SyncResolver.html"><code>SyncResolver</code></a> for an example.
0N/A * This <code>SyncResolver</code> object will mirror the <code>RowSet</code>
0N/A * object that generated the exception, except that it will contain only the values
0N/A * from the data source that are in conflict. All other values in the <code>SyncResolver</code>
0N/A * object will be <code>null</code>.
0N/A * <P>
0N/A * The <code>SyncResolver</code> object may be used to examine and resolve
0N/A * each conflict in a row and then go to the next row with a conflict to
0N/A * repeat the procedure.
0N/A * <P>
0N/A * A <code>SyncProviderException</code> object may or may not contain a description of the
0N/A * condition causing the exception. The inherited method <code>getMessage</code> may be
0N/A * called to retrieve the description if there is one.
0N/A *
0N/A * @author Jonathan Bruce
0N/A * @see javax.sql.rowset.spi.SyncFactory
0N/A * @see javax.sql.rowset.spi.SyncResolver
0N/A * @see javax.sql.rowset.spi.SyncFactoryException
0N/A */
0N/Apublic class SyncProviderException extends java.sql.SQLException {
0N/A
0N/A /**
0N/A * The instance of <code>javax.sql.rowset.spi.SyncResolver</code> that
0N/A * this <code>SyncProviderException</code> object will return when its
0N/A * <code>getSyncResolver</code> method is called.
0N/A */
0N/A private SyncResolver syncResolver = null;
0N/A
0N/A /**
0N/A * Creates a new <code>SyncProviderException</code> object without a detail message.
0N/A */
0N/A public SyncProviderException() {
0N/A super();
0N/A }
0N/A
0N/A /**
0N/A * Constructs a <code>SyncProviderException</code> object with the specified
0N/A * detail message.
0N/A *
0N/A * @param msg the detail message
0N/A */
0N/A public SyncProviderException(String msg) {
0N/A super(msg);
0N/A }
0N/A
0N/A /**
0N/A * Constructs a <code>SyncProviderException</code> object with the specified
0N/A * <code>SyncResolver</code> instance.
0N/A *
0N/A * @param syncResolver the <code>SyncResolver</code> instance used to
0N/A * to process the synchronization conflicts
0N/A * @throws IllegalArgumentException if the <code>SyncResolver</code> object
0N/A * is <code>null</code>.
0N/A */
0N/A public SyncProviderException(SyncResolver syncResolver) {
0N/A if (syncResolver == null) {
0N/A throw new IllegalArgumentException("Cannot instantiate a SyncProviderException " +
0N/A "with a null SyncResolver object");
0N/A } else {
0N/A this.syncResolver = syncResolver;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Retrieves the <code>SyncResolver</code> object that has been set for
0N/A * this <code>SyncProviderException</code> object, or
0N/A * if none has been set, an instance of the default <code>SyncResolver</code>
0N/A * implementation included in the reference implementation.
0N/A * <P>
0N/A * If a <code>SyncProviderException</code> object is thrown, an application
0N/A * may use this method to generate a <code>SyncResolver</code> object
0N/A * with which to resolve the conflict or conflicts that caused the
0N/A * exception to be thrown.
0N/A *
0N/A * @return the <code>SyncResolver</code> object set for this
0N/A * <code>SyncProviderException</code> object or, if none has
0N/A * been set, an instance of the default <code>SyncResolver</code>
0N/A * implementation. In addition, the default <code>SyncResolver</code>
0N/A * implementation is also returned if the <code>SyncResolver()</code> or
0N/A * <code>SyncResolver(String)</code> constructors are used to instantiate
0N/A * the <code>SyncResolver</code> instance.
0N/A */
0N/A public SyncResolver getSyncResolver() {
0N/A if (syncResolver != null) {
0N/A return syncResolver;
0N/A } else {
0N/A try {
0N/A syncResolver = new com.sun.rowset.internal.SyncResolverImpl();
0N/A } catch (SQLException sqle) {
0N/A }
0N/A return syncResolver;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the <code>SyncResolver</code> object for this
0N/A * <code>SyncProviderException</code> object to the one supplied.
0N/A * If the argument supplied is <code>null</code>, a call to the method
0N/A * <code>getSyncResolver</code> will return the default reference
0N/A * implementation of the <code>SyncResolver</code> interface.
0N/A *
0N/A * @param syncResolver the <code>SyncResolver</code> object to be set;
0N/A * cannot be <code>null</code>
0N/A * @throws IllegalArgumentException if the <code>SyncResolver</code> object
0N/A * is <code>null</code>.
0N/A * @see #getSyncResolver
0N/A */
0N/A public void setSyncResolver(SyncResolver syncResolver) {
0N/A if (syncResolver == null) {
0N/A throw new IllegalArgumentException("Cannot set a null SyncResolver " +
0N/A "object");
0N/A } else {
0N/A this.syncResolver = syncResolver;
0N/A }
0N/A }
0N/A
0N/A static final long serialVersionUID = -939908523620640692L;
0N/A
0N/A}