author | gromero |
Tue, 04 Sep 2018 11:46:23 -0400 | |
changeset 51629 | 78c7f0c7827d |
parent 51181 | 01b8120f867a |
child 54106 | 9a90236ab64c |
permissions | -rw-r--r-- |
2 | 1 |
/* |
18564 | 2 |
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.sql.rowset.serial; |
|
27 |
||
28 |
import java.sql.*; |
|
29 |
import javax.sql.*; |
|
30 |
import java.io.*; |
|
31 |
import java.math.*; |
|
11683
5e02efd89af6
7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents:
11129
diff
changeset
|
32 |
import java.util.Arrays; |
2 | 33 |
import java.util.Map; |
34 |
import java.util.Vector; |
|
35 |
||
36 |
import javax.sql.rowset.*; |
|
37 |
||
38 |
/** |
|
39 |
* A serialized mapping in the Java programming language of an SQL |
|
40 |
* structured type. Each attribute that is not already serialized |
|
41 |
* is mapped to a serialized form, and if an attribute is itself |
|
42 |
* a structured type, each of its attributes that is not already |
|
43 |
* serialized is mapped to a serialized form. |
|
44 |
* <P> |
|
45 |
* In addition, the structured type is custom mapped to a class in the |
|
46 |
* Java programming language if there is such a mapping, as are |
|
47 |
* its attributes, if appropriate. |
|
48 |
* <P> |
|
49 |
* The <code>SerialStruct</code> class provides a constructor for creating |
|
50 |
* an instance from a <code>Struct</code> object, a method for retrieving |
|
51 |
* the SQL type name of the SQL structured type in the database, and methods |
|
52 |
* for retrieving its attribute values. |
|
14781
701d0765f75f
8004357: Implement various methods in SerialBlob/Clob/Array and specify Thread Safety
lancea
parents:
14409
diff
changeset
|
53 |
* |
18564 | 54 |
* <h3> Thread safety </h3> |
14781
701d0765f75f
8004357: Implement various methods in SerialBlob/Clob/Array and specify Thread Safety
lancea
parents:
14409
diff
changeset
|
55 |
* |
701d0765f75f
8004357: Implement various methods in SerialBlob/Clob/Array and specify Thread Safety
lancea
parents:
14409
diff
changeset
|
56 |
* A SerialStruct is not safe for use by multiple concurrent threads. If a |
701d0765f75f
8004357: Implement various methods in SerialBlob/Clob/Array and specify Thread Safety
lancea
parents:
14409
diff
changeset
|
57 |
* SerialStruct is to be used by more than one thread then access to the |
701d0765f75f
8004357: Implement various methods in SerialBlob/Clob/Array and specify Thread Safety
lancea
parents:
14409
diff
changeset
|
58 |
* SerialStruct should be controlled by appropriate synchronization. |
701d0765f75f
8004357: Implement various methods in SerialBlob/Clob/Array and specify Thread Safety
lancea
parents:
14409
diff
changeset
|
59 |
* |
24968
3308660aa3f2
8046389: Add missing @since tag under javax.sql.**
henryjen
parents:
18564
diff
changeset
|
60 |
* @since 1.5 |
2 | 61 |
*/ |
62 |
public class SerialStruct implements Struct, Serializable, Cloneable { |
|
63 |
||
64 |
||
65 |
/** |
|
66 |
* The SQL type name for the structured type that this |
|
67 |
* <code>SerialStruct</code> object represents. This is the name |
|
68 |
* used in the SQL definition of the SQL structured type. |
|
69 |
* |
|
70 |
* @serial |
|
71 |
*/ |
|
72 |
private String SQLTypeName; |
|
73 |
||
74 |
/** |
|
75 |
* An array of <code>Object</code> instances in which each |
|
76 |
* element is an attribute of the SQL structured type that this |
|
77 |
* <code>SerialStruct</code> object represents. The attributes are |
|
78 |
* ordered according to their order in the definition of the |
|
79 |
* SQL structured type. |
|
80 |
* |
|
81 |
* @serial |
|
82 |
*/ |
|
83 |
private Object attribs[]; |
|
84 |
||
85 |
/** |
|
86 |
* Constructs a <code>SerialStruct</code> object from the given |
|
87 |
* <code>Struct</code> object, using the given <code>java.util.Map</code> |
|
88 |
* object for custom mapping the SQL structured type or any of its |
|
89 |
* attributes that are SQL structured types. |
|
90 |
* |
|
18149
5997c9aedb0e
8016101: Fix typo in SerialRef and missing @param in SerialStruct
lancea
parents:
14781
diff
changeset
|
91 |
* @param in an instance of {@code Struct} |
2 | 92 |
* @param map a <code>java.util.Map</code> object in which |
93 |
* each entry consists of 1) a <code>String</code> object |
|
94 |
* giving the fully qualified name of a UDT and 2) the |
|
95 |
* <code>Class</code> object for the <code>SQLData</code> implementation |
|
96 |
* that defines how the UDT is to be mapped |
|
97 |
* @throws SerialException if an error occurs |
|
98 |
* @see java.sql.Struct |
|
99 |
*/ |
|
100 |
public SerialStruct(Struct in, Map<String,Class<?>> map) |
|
101 |
throws SerialException |
|
102 |
{ |
|
103 |
||
104 |
try { |
|
105 |
||
106 |
// get the type name |
|
6692
aef4e294026f
6988993: Address Findbugs warnings for the use of String Constructor
lancea
parents:
5506
diff
changeset
|
107 |
SQLTypeName = in.getSQLTypeName(); |
2 | 108 |
System.out.println("SQLTypeName: " + SQLTypeName); |
109 |
||
110 |
// get the attributes of the struct |
|
111 |
attribs = in.getAttributes(map); |
|
112 |
||
113 |
/* |
|
114 |
* the array may contain further Structs |
|
115 |
* and/or classes that have been mapped, |
|
116 |
* other types that we have to serialize |
|
117 |
*/ |
|
118 |
mapToSerial(map); |
|
119 |
||
120 |
} catch (SQLException e) { |
|
121 |
throw new SerialException(e.getMessage()); |
|
122 |
} |
|
123 |
} |
|
124 |
||
125 |
/** |
|
126 |
* Constructs a <code>SerialStruct</code> object from the |
|
127 |
* given <code>SQLData</code> object, using the given type |
|
128 |
* map to custom map it to a class in the Java programming |
|
129 |
* language. The type map gives the SQL type and the class |
|
130 |
* to which it is mapped. The <code>SQLData</code> object |
|
131 |
* defines the class to which the SQL type will be mapped. |
|
132 |
* |
|
133 |
* @param in an instance of the <code>SQLData</code> class |
|
134 |
* that defines the mapping of the SQL structured |
|
135 |
* type to one or more objects in the Java programming language |
|
136 |
* @param map a <code>java.util.Map</code> object in which |
|
137 |
* each entry consists of 1) a <code>String</code> object |
|
138 |
* giving the fully qualified name of a UDT and 2) the |
|
139 |
* <code>Class</code> object for the <code>SQLData</code> implementation |
|
140 |
* that defines how the UDT is to be mapped |
|
141 |
* @throws SerialException if an error occurs |
|
142 |
*/ |
|
143 |
public SerialStruct(SQLData in, Map<String,Class<?>> map) |
|
144 |
throws SerialException |
|
145 |
{ |
|
146 |
||
147 |
try { |
|
148 |
||
149 |
//set the type name |
|
6692
aef4e294026f
6988993: Address Findbugs warnings for the use of String Constructor
lancea
parents:
5506
diff
changeset
|
150 |
SQLTypeName = in.getSQLTypeName(); |
2 | 151 |
|
11129
f9ad1aadf3fa
7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents:
6692
diff
changeset
|
152 |
Vector<Object> tmp = new Vector<>(); |
2 | 153 |
in.writeSQL(new SQLOutputImpl(tmp, map)); |
154 |
attribs = tmp.toArray(); |
|
155 |
||
156 |
} catch (SQLException e) { |
|
157 |
throw new SerialException(e.getMessage()); |
|
158 |
} |
|
159 |
} |
|
160 |
||
161 |
||
162 |
/** |
|
163 |
* Retrieves the SQL type name for this <code>SerialStruct</code> |
|
164 |
* object. This is the name used in the SQL definition of the |
|
165 |
* structured type |
|
166 |
* |
|
167 |
* @return a <code>String</code> object representing the SQL |
|
168 |
* type name for the SQL structured type that this |
|
169 |
* <code>SerialStruct</code> object represents |
|
170 |
* @throws SerialException if an error occurs |
|
171 |
*/ |
|
172 |
public String getSQLTypeName() throws SerialException { |
|
173 |
return SQLTypeName; |
|
174 |
} |
|
175 |
||
176 |
/** |
|
177 |
* Retrieves an array of <code>Object</code> values containing the |
|
178 |
* attributes of the SQL structured type that this |
|
179 |
* <code>SerialStruct</code> object represents. |
|
180 |
* |
|
181 |
* @return an array of <code>Object</code> values, with each |
|
182 |
* element being an attribute of the SQL structured type |
|
183 |
* that this <code>SerialStruct</code> object represents |
|
184 |
* @throws SerialException if an error occurs |
|
185 |
*/ |
|
186 |
public Object[] getAttributes() throws SerialException { |
|
11683
5e02efd89af6
7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents:
11129
diff
changeset
|
187 |
Object[] val = this.attribs; |
5e02efd89af6
7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents:
11129
diff
changeset
|
188 |
return (val == null) ? null : Arrays.copyOf(val, val.length); |
2 | 189 |
} |
190 |
||
191 |
/** |
|
192 |
* Retrieves the attributes for the SQL structured type that |
|
193 |
* this <code>SerialStruct</code> represents as an array of |
|
194 |
* <code>Object</code> values, using the given type map for |
|
195 |
* custom mapping if appropriate. |
|
196 |
* |
|
197 |
* @param map a <code>java.util.Map</code> object in which |
|
198 |
* each entry consists of 1) a <code>String</code> object |
|
199 |
* giving the fully qualified name of a UDT and 2) the |
|
200 |
* <code>Class</code> object for the <code>SQLData</code> implementation |
|
201 |
* that defines how the UDT is to be mapped |
|
202 |
* @return an array of <code>Object</code> values, with each |
|
203 |
* element being an attribute of the SQL structured |
|
204 |
* type that this <code>SerialStruct</code> object |
|
205 |
* represents |
|
206 |
* @throws SerialException if an error occurs |
|
207 |
*/ |
|
208 |
public Object[] getAttributes(Map<String,Class<?>> map) |
|
209 |
throws SerialException |
|
210 |
{ |
|
11683
5e02efd89af6
7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents:
11129
diff
changeset
|
211 |
Object[] val = this.attribs; |
5e02efd89af6
7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents:
11129
diff
changeset
|
212 |
return (val == null) ? null : Arrays.copyOf(val, val.length); |
2 | 213 |
} |
214 |
||
215 |
||
216 |
/** |
|
217 |
* Maps attributes of an SQL structured type that are not |
|
218 |
* serialized to a serialized form, using the given type map |
|
219 |
* for custom mapping when appropriate. The following types |
|
220 |
* in the Java programming language are mapped to their |
|
221 |
* serialized forms: <code>Struct</code>, <code>SQLData</code>, |
|
222 |
* <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, and |
|
223 |
* <code>Array</code>. |
|
224 |
* <P> |
|
225 |
* This method is called internally and is not used by an |
|
226 |
* application programmer. |
|
227 |
* |
|
228 |
* @param map a <code>java.util.Map</code> object in which |
|
229 |
* each entry consists of 1) a <code>String</code> object |
|
230 |
* giving the fully qualified name of a UDT and 2) the |
|
231 |
* <code>Class</code> object for the <code>SQLData</code> implementation |
|
232 |
* that defines how the UDT is to be mapped |
|
233 |
* @throws SerialException if an error occurs |
|
234 |
*/ |
|
11129
f9ad1aadf3fa
7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents:
6692
diff
changeset
|
235 |
private void mapToSerial(Map<String,Class<?>> map) throws SerialException { |
2 | 236 |
|
237 |
try { |
|
238 |
||
239 |
for (int i = 0; i < attribs.length; i++) { |
|
240 |
if (attribs[i] instanceof Struct) { |
|
241 |
attribs[i] = new SerialStruct((Struct)attribs[i], map); |
|
242 |
} else if (attribs[i] instanceof SQLData) { |
|
243 |
attribs[i] = new SerialStruct((SQLData)attribs[i], map); |
|
244 |
} else if (attribs[i] instanceof Blob) { |
|
245 |
attribs[i] = new SerialBlob((Blob)attribs[i]); |
|
246 |
} else if (attribs[i] instanceof Clob) { |
|
247 |
attribs[i] = new SerialClob((Clob)attribs[i]); |
|
248 |
} else if (attribs[i] instanceof Ref) { |
|
249 |
attribs[i] = new SerialRef((Ref)attribs[i]); |
|
250 |
} else if (attribs[i] instanceof java.sql.Array) { |
|
251 |
attribs[i] = new SerialArray((java.sql.Array)attribs[i], map); |
|
252 |
} |
|
253 |
} |
|
254 |
||
255 |
} catch (SQLException e) { |
|
256 |
throw new SerialException(e.getMessage()); |
|
257 |
} |
|
258 |
return; |
|
259 |
} |
|
260 |
||
261 |
/** |
|
14409
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
262 |
* Compares this SerialStruct to the specified object. The result is |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
263 |
* {@code true} if and only if the argument is not {@code null} and is a |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
264 |
* {@code SerialStruct} object whose attributes are identical to this |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
265 |
* object's attributes |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
266 |
* |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
267 |
* @param obj The object to compare this {@code SerialStruct} against |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
268 |
* |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
269 |
* @return {@code true} if the given object represents a {@code SerialStruct} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
270 |
* equivalent to this SerialStruct, {@code false} otherwise |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
271 |
* |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
272 |
*/ |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
273 |
public boolean equals(Object obj) { |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
274 |
if (this == obj) { |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
275 |
return true; |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
276 |
} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
277 |
if (obj instanceof SerialStruct) { |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
278 |
SerialStruct ss = (SerialStruct)obj; |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
279 |
return SQLTypeName.equals(ss.SQLTypeName) && |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
280 |
Arrays.equals(attribs, ss.attribs); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
281 |
} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
282 |
return false; |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
283 |
} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
284 |
|
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
285 |
/** |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
286 |
* Returns a hash code for this {@code SerialStruct}. The hash code for a |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
287 |
* {@code SerialStruct} object is computed using the hash codes |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
288 |
* of the attributes of the {@code SerialStruct} object and its |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
289 |
* {@code SQLTypeName} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
290 |
* |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
291 |
* @return a hash code value for this object. |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
292 |
*/ |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
293 |
public int hashCode() { |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
294 |
return ((31 + Arrays.hashCode(attribs)) * 31) * 31 |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
295 |
+ SQLTypeName.hashCode(); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
296 |
} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
297 |
|
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
298 |
/** |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
299 |
* Returns a clone of this {@code SerialStruct}. The copy will contain a |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
300 |
* reference to a clone of the underlying attribs array, not a reference |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
301 |
* to the original underlying attribs array of this {@code SerialStruct} object. |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
302 |
* |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
303 |
* @return a clone of this SerialStruct |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
304 |
*/ |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
305 |
public Object clone() { |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
306 |
try { |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
307 |
SerialStruct ss = (SerialStruct) super.clone(); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
308 |
ss.attribs = Arrays.copyOf(attribs, attribs.length); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
309 |
return ss; |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
310 |
} catch (CloneNotSupportedException ex) { |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
311 |
// this shouldn't happen, since we are Cloneable |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
312 |
throw new InternalError(); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
313 |
} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
314 |
|
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
315 |
} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
316 |
|
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
317 |
/** |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
318 |
* readObject is called to restore the state of the {@code SerialStruct} from |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
319 |
* a stream. |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
320 |
*/ |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
321 |
private void readObject(ObjectInputStream s) |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
322 |
throws IOException, ClassNotFoundException { |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
323 |
|
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
324 |
ObjectInputStream.GetField fields = s.readFields(); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
325 |
Object[] tmp = (Object[])fields.get("attribs", null); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
326 |
attribs = tmp == null ? null : tmp.clone(); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
327 |
SQLTypeName = (String)fields.get("SQLTypeName", null); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
328 |
} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
329 |
|
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
330 |
/** |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
331 |
* writeObject is called to save the state of the {@code SerialStruct} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
332 |
* to a stream. |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
333 |
*/ |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
334 |
private void writeObject(ObjectOutputStream s) |
51181
01b8120f867a
8208060: Additional corrections of serial-related declarations
darcy
parents:
47216
diff
changeset
|
335 |
throws IOException { |
14409
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
336 |
|
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
337 |
ObjectOutputStream.PutField fields = s.putFields(); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
338 |
fields.put("attribs", attribs); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
339 |
fields.put("SQLTypeName", SQLTypeName); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
340 |
s.writeFields(); |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
341 |
} |
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
342 |
|
d879c92507ec
8002212: adding read/writeObject to additional SerialXXX classes
lancea
parents:
11683
diff
changeset
|
343 |
/** |
6692
aef4e294026f
6988993: Address Findbugs warnings for the use of String Constructor
lancea
parents:
5506
diff
changeset
|
344 |
* The identifier that assists in the serialization of this |
2 | 345 |
* <code>SerialStruct</code> object. |
346 |
*/ |
|
347 |
static final long serialVersionUID = -8322445504027483372L; |
|
348 |
} |