Path: blob/master/src/java.sql.rowset/share/classes/javax/sql/rowset/spi/SyncProviderException.java
40948 views
/*1* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.sql.rowset.spi;2627import java.sql.SQLException;28import javax.sql.rowset.*;2930/**31* Indicates an error with the <code>SyncProvider</code> mechanism. This exception32* is created by a <code>SyncProvider</code> abstract class extension if it33* encounters violations in reading from or writing to the originating data source.34* <P>35* If it is implemented to do so, the <code>SyncProvider</code> object may also create a36* <code>SyncResolver</code> object and either initialize the <code>SyncProviderException</code>37* object with it at construction time or set it with the <code>SyncProvider</code> object at38* a later time.39* <P>40* The method <code>acceptChanges</code> will throw this exception after the writer41* has finished checking for conflicts and has found one or more conflicts. An42* application may catch a <code>SyncProviderException</code> object and call its43* <code>getSyncResolver</code> method to get its <code>SyncResolver</code> object.44* See the code fragment in the interface comment for45* <a href="SyncResolver.html"><code>SyncResolver</code></a> for an example.46* This <code>SyncResolver</code> object will mirror the <code>RowSet</code>47* object that generated the exception, except that it will contain only the values48* from the data source that are in conflict. All other values in the <code>SyncResolver</code>49* object will be <code>null</code>.50* <P>51* The <code>SyncResolver</code> object may be used to examine and resolve52* each conflict in a row and then go to the next row with a conflict to53* repeat the procedure.54* <P>55* A <code>SyncProviderException</code> object may or may not contain a description of the56* condition causing the exception. The inherited method <code>getMessage</code> may be57* called to retrieve the description if there is one.58*59* @author Jonathan Bruce60* @see javax.sql.rowset.spi.SyncFactory61* @see javax.sql.rowset.spi.SyncResolver62* @see javax.sql.rowset.spi.SyncFactoryException63* @since 1.564*/65public class SyncProviderException extends java.sql.SQLException {6667/**68* The instance of <code>javax.sql.rowset.spi.SyncResolver</code> that69* this <code>SyncProviderException</code> object will return when its70* <code>getSyncResolver</code> method is called.71*/72@SuppressWarnings("serial") // Not statically typed as Serializable73private SyncResolver syncResolver = null;7475/**76* Creates a new <code>SyncProviderException</code> object without a detail message.77*/78public SyncProviderException() {79super();80}8182/**83* Constructs a <code>SyncProviderException</code> object with the specified84* detail message.85*86* @param msg the detail message87*/88public SyncProviderException(String msg) {89super(msg);90}9192/**93* Constructs a <code>SyncProviderException</code> object with the specified94* <code>SyncResolver</code> instance.95*96* @param syncResolver the <code>SyncResolver</code> instance used to97* to process the synchronization conflicts98* @throws IllegalArgumentException if the <code>SyncResolver</code> object99* is <code>null</code>.100*/101public SyncProviderException(SyncResolver syncResolver) {102if (syncResolver == null) {103throw new IllegalArgumentException("Cannot instantiate a SyncProviderException " +104"with a null SyncResolver object");105} else {106this.syncResolver = syncResolver;107}108}109110/**111* Retrieves the <code>SyncResolver</code> object that has been set for112* this <code>SyncProviderException</code> object, or113* if none has been set, an instance of the default <code>SyncResolver</code>114* implementation included in the reference implementation.115* <P>116* If a <code>SyncProviderException</code> object is thrown, an application117* may use this method to generate a <code>SyncResolver</code> object118* with which to resolve the conflict or conflicts that caused the119* exception to be thrown.120*121* @return the <code>SyncResolver</code> object set for this122* <code>SyncProviderException</code> object or, if none has123* been set, an instance of the default <code>SyncResolver</code>124* implementation. In addition, the default <code>SyncResolver</code>125* implementation is also returned if the <code>SyncResolver()</code> or126* <code>SyncResolver(String)</code> constructors are used to instantiate127* the <code>SyncResolver</code> instance.128*/129public SyncResolver getSyncResolver() {130if (syncResolver != null) {131return syncResolver;132} else {133try {134syncResolver = new com.sun.rowset.internal.SyncResolverImpl();135} catch (SQLException sqle) {136}137return syncResolver;138}139}140141/**142* Sets the <code>SyncResolver</code> object for this143* <code>SyncProviderException</code> object to the one supplied.144* If the argument supplied is <code>null</code>, a call to the method145* <code>getSyncResolver</code> will return the default reference146* implementation of the <code>SyncResolver</code> interface.147*148* @param syncResolver the <code>SyncResolver</code> object to be set;149* cannot be <code>null</code>150* @throws IllegalArgumentException if the <code>SyncResolver</code> object151* is <code>null</code>.152* @see #getSyncResolver153*/154public void setSyncResolver(SyncResolver syncResolver) {155if (syncResolver == null) {156throw new IllegalArgumentException("Cannot set a null SyncResolver " +157"object");158} else {159this.syncResolver = syncResolver;160}161}162163static final long serialVersionUID = -939908523620640692L;164165}166167168