Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.sql.rowset/share/classes/javax/sql/rowset/spi/SyncProviderException.java
40948 views
1
/*
2
* Copyright (c) 2003, 2019, 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
* @since 1.5
65
*/
66
public class SyncProviderException extends java.sql.SQLException {
67
68
/**
69
* The instance of <code>javax.sql.rowset.spi.SyncResolver</code> that
70
* this <code>SyncProviderException</code> object will return when its
71
* <code>getSyncResolver</code> method is called.
72
*/
73
@SuppressWarnings("serial") // Not statically typed as Serializable
74
private SyncResolver syncResolver = null;
75
76
/**
77
* Creates a new <code>SyncProviderException</code> object without a detail message.
78
*/
79
public SyncProviderException() {
80
super();
81
}
82
83
/**
84
* Constructs a <code>SyncProviderException</code> object with the specified
85
* detail message.
86
*
87
* @param msg the detail message
88
*/
89
public SyncProviderException(String msg) {
90
super(msg);
91
}
92
93
/**
94
* Constructs a <code>SyncProviderException</code> object with the specified
95
* <code>SyncResolver</code> instance.
96
*
97
* @param syncResolver the <code>SyncResolver</code> instance used to
98
* to process the synchronization conflicts
99
* @throws IllegalArgumentException if the <code>SyncResolver</code> object
100
* is <code>null</code>.
101
*/
102
public SyncProviderException(SyncResolver syncResolver) {
103
if (syncResolver == null) {
104
throw new IllegalArgumentException("Cannot instantiate a SyncProviderException " +
105
"with a null SyncResolver object");
106
} else {
107
this.syncResolver = syncResolver;
108
}
109
}
110
111
/**
112
* Retrieves the <code>SyncResolver</code> object that has been set for
113
* this <code>SyncProviderException</code> object, or
114
* if none has been set, an instance of the default <code>SyncResolver</code>
115
* implementation included in the reference implementation.
116
* <P>
117
* If a <code>SyncProviderException</code> object is thrown, an application
118
* may use this method to generate a <code>SyncResolver</code> object
119
* with which to resolve the conflict or conflicts that caused the
120
* exception to be thrown.
121
*
122
* @return the <code>SyncResolver</code> object set for this
123
* <code>SyncProviderException</code> object or, if none has
124
* been set, an instance of the default <code>SyncResolver</code>
125
* implementation. In addition, the default <code>SyncResolver</code>
126
* implementation is also returned if the <code>SyncResolver()</code> or
127
* <code>SyncResolver(String)</code> constructors are used to instantiate
128
* the <code>SyncResolver</code> instance.
129
*/
130
public SyncResolver getSyncResolver() {
131
if (syncResolver != null) {
132
return syncResolver;
133
} else {
134
try {
135
syncResolver = new com.sun.rowset.internal.SyncResolverImpl();
136
} catch (SQLException sqle) {
137
}
138
return syncResolver;
139
}
140
}
141
142
/**
143
* Sets the <code>SyncResolver</code> object for this
144
* <code>SyncProviderException</code> object to the one supplied.
145
* If the argument supplied is <code>null</code>, a call to the method
146
* <code>getSyncResolver</code> will return the default reference
147
* implementation of the <code>SyncResolver</code> interface.
148
*
149
* @param syncResolver the <code>SyncResolver</code> object to be set;
150
* cannot be <code>null</code>
151
* @throws IllegalArgumentException if the <code>SyncResolver</code> object
152
* is <code>null</code>.
153
* @see #getSyncResolver
154
*/
155
public void setSyncResolver(SyncResolver syncResolver) {
156
if (syncResolver == null) {
157
throw new IllegalArgumentException("Cannot set a null SyncResolver " +
158
"object");
159
} else {
160
this.syncResolver = syncResolver;
161
}
162
}
163
164
static final long serialVersionUID = -939908523620640692L;
165
166
}
167
168