Showing the changes to java/pkg/javax/sql/rowset/spi/SyncProviderException.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,164 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +package javax.sql.rowset.spi; | |
| 27 | + | |
| 28 | +import java.sql.SQLException; | |
| 29 | +import javax.sql.rowset.*; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * Indicates an error with the <code>SyncProvider</code> mechanism. This exception | |
| 33 | + * is created by a <code>SyncProvider</code> abstract class extension if it | |
| 34 | + * encounters violations in reading from or writing to the originating data source. | |
| 35 | + * <P> | |
| 36 | + * If it is implemented to do so, the <code>SyncProvider</code> object may also create a | |
| 37 | + * <code>SyncResolver</code> object and either initialize the <code>SyncProviderException</code> | |
| 38 | + * object with it at construction time or set it with the <code>SyncProvider</code> object at | |
| 39 | + * a later time. | |
| 40 | + * <P> | |
| 41 | + * The method <code>acceptChanges</code> will throw this exception after the writer | |
| 42 | + * has finished checking for conflicts and has found one or more conflicts. An | |
| 43 | + * application may catch a <code>SyncProviderException</code> object and call its | |
| 44 | + * <code>getSyncResolver</code> method to get its <code>SyncResolver</code> object. | |
| 45 | + * See the code fragment in the interface comment for | |
| 46 | + * <a href="SyncResolver.html"><code>SyncResolver</code></a> for an example. | |
| 47 | + * This <code>SyncResolver</code> object will mirror the <code>RowSet</code> | |
| 48 | + * object that generated the exception, except that it will contain only the values | |
| 49 | + * from the data source that are in conflict. All other values in the <code>SyncResolver</code> | |
| 50 | + * object will be <code>null</code>. | |
| 51 | + * <P> | |
| 52 | + * The <code>SyncResolver</code> object may be used to examine and resolve | |
| 53 | + * each conflict in a row and then go to the next row with a conflict to | |
| 54 | + * repeat the procedure. | |
| 55 | + * <P> | |
| 56 | + * A <code>SyncProviderException</code> object may or may not contain a description of the | |
| 57 | + * condition causing the exception. The inherited method <code>getMessage</code> may be | |
| 58 | + * called to retrieve the description if there is one. | |
| 59 | + * | |
| 60 | + * @author Jonathan Bruce | |
| 61 | + * @see javax.sql.rowset.spi.SyncFactory | |
| 62 | + * @see javax.sql.rowset.spi.SyncResolver | |
| 63 | + * @see javax.sql.rowset.spi.SyncFactoryException | |
| 64 | + */ | |
| 65 | +public class SyncProviderException extends java.sql.SQLException { | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * The instance of <code>javax.sql.rowset.spi.SyncResolver</code> that | |
| 69 | + * this <code>SyncProviderException</code> object will return when its | |
| 70 | + * <code>getSyncResolver</code> method is called. | |
| 71 | + */ | |
| 72 | + private SyncResolver syncResolver = null; | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * Creates a new <code>SyncProviderException</code> object without a detail message. | |
| 76 | + */ | |
| 77 | + public SyncProviderException() { | |
| 78 | + super(); | |
| 79 | + } | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * Constructs a <code>SyncProviderException</code> object with the specified | |
| 83 | + * detail message. | |
| 84 | + * | |
| 85 | + * @param msg the detail message | |
| 86 | + */ | |
| 87 | + public SyncProviderException(String msg) { | |
| 88 | + super(msg); | |
| 89 | + } | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * Constructs a <code>SyncProviderException</code> object with the specified | |
| 93 | + * <code>SyncResolver</code> instance. | |
| 94 | + * | |
| 95 | + * @param syncResolver the <code>SyncResolver</code> instance used to | |
| 96 | + * to process the synchronization conflicts | |
| 97 | + * @throws IllegalArgumentException if the <code>SyncResolver</code> object | |
| 98 | + * is <code>null</code>. | |
| 99 | + */ | |
| 100 | + public SyncProviderException(SyncResolver syncResolver) { | |
| 101 | + if (syncResolver == null) { | |
| 102 | + throw new IllegalArgumentException("Cannot instantiate a SyncProviderException " + | |
| 103 | + "with a null SyncResolver object"); | |
| 104 | + } else { | |
| 105 | + this.syncResolver = syncResolver; | |
| 106 | + } | |
| 107 | + } | |
| 108 | + | |
| 109 | + /** | |
| 110 | + * Retrieves the <code>SyncResolver</code> object that has been set for | |
| 111 | + * this <code>SyncProviderException</code> object, or | |
| 112 | + * if none has been set, an instance of the default <code>SyncResolver</code> | |
| 113 | + * implementation included in the reference implementation. | |
| 114 | + * <P> | |
| 115 | + * If a <code>SyncProviderException</code> object is thrown, an application | |
| 116 | + * may use this method to generate a <code>SyncResolver</code> object | |
| 117 | + * with which to resolve the conflict or conflicts that caused the | |
| 118 | + * exception to be thrown. | |
| 119 | + * | |
| 120 | + * @return the <code>SyncResolver</code> object set for this | |
| 121 | + * <code>SyncProviderException</code> object or, if none has | |
| 122 | + * been set, an instance of the default <code>SyncResolver</code> | |
| 123 | + * implementation. In addition, the default <code>SyncResolver</code> | |
| 124 | + * implementation is also returned if the <code>SyncResolver()</code> or | |
| 125 | + * <code>SyncResolver(String)</code> constructors are used to instantiate | |
| 126 | + * the <code>SyncResolver</code> instance. | |
| 127 | + */ | |
| 128 | + public SyncResolver getSyncResolver() { | |
| 129 | + if (syncResolver != null) { | |
| 130 | + return syncResolver; | |
| 131 | + } else { | |
| 132 | + try { | |
| 133 | + syncResolver = new com.sun.rowset.internal.SyncResolverImpl(); | |
| 134 | + } catch (SQLException sqle) { | |
| 135 | + } | |
| 136 | + return syncResolver; | |
| 137 | + } | |
| 138 | + } | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * Sets the <code>SyncResolver</code> object for this | |
| 142 | + * <code>SyncProviderException</code> object to the one supplied. | |
| 143 | + * If the argument supplied is <code>null</code>, a call to the method | |
| 144 | + * <code>getSyncResolver</code> will return the default reference | |
| 145 | + * implementation of the <code>SyncResolver</code> interface. | |
| 146 | + * | |
| 147 | + * @param syncResolver the <code>SyncResolver</code> object to be set; | |
| 148 | + * cannot be <code>null</code> | |
| 149 | + * @throws IllegalArgumentException if the <code>SyncResolver</code> object | |
| 150 | + * is <code>null</code>. | |
| 151 | + * @see #getSyncResolver | |
| 152 | + */ | |
| 153 | + public void setSyncResolver(SyncResolver syncResolver) { | |
| 154 | + if (syncResolver == null) { | |
| 155 | + throw new IllegalArgumentException("Cannot set a null SyncResolver " + | |
| 156 | + "object"); | |
| 157 | + } else { | |
| 158 | + this.syncResolver = syncResolver; | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 162 | + static final long serialVersionUID = -939908523620640692L; | |
| 163 | + | |
| 164 | +} | |