248 } |
248 } |
249 return; |
249 return; |
250 } |
250 } |
251 |
251 |
252 /** |
252 /** |
|
253 * Compares this SerialStruct to the specified object. The result is |
|
254 * {@code true} if and only if the argument is not {@code null} and is a |
|
255 * {@code SerialStruct} object whose attributes are identical to this |
|
256 * object's attributes |
|
257 * |
|
258 * @param obj The object to compare this {@code SerialStruct} against |
|
259 * |
|
260 * @return {@code true} if the given object represents a {@code SerialStruct} |
|
261 * equivalent to this SerialStruct, {@code false} otherwise |
|
262 * |
|
263 */ |
|
264 public boolean equals(Object obj) { |
|
265 if (this == obj) { |
|
266 return true; |
|
267 } |
|
268 if (obj instanceof SerialStruct) { |
|
269 SerialStruct ss = (SerialStruct)obj; |
|
270 return SQLTypeName.equals(ss.SQLTypeName) && |
|
271 Arrays.equals(attribs, ss.attribs); |
|
272 } |
|
273 return false; |
|
274 } |
|
275 |
|
276 /** |
|
277 * Returns a hash code for this {@code SerialStruct}. The hash code for a |
|
278 * {@code SerialStruct} object is computed using the hash codes |
|
279 * of the attributes of the {@code SerialStruct} object and its |
|
280 * {@code SQLTypeName} |
|
281 * |
|
282 * @return a hash code value for this object. |
|
283 */ |
|
284 public int hashCode() { |
|
285 return ((31 + Arrays.hashCode(attribs)) * 31) * 31 |
|
286 + SQLTypeName.hashCode(); |
|
287 } |
|
288 |
|
289 /** |
|
290 * Returns a clone of this {@code SerialStruct}. The copy will contain a |
|
291 * reference to a clone of the underlying attribs array, not a reference |
|
292 * to the original underlying attribs array of this {@code SerialStruct} object. |
|
293 * |
|
294 * @return a clone of this SerialStruct |
|
295 */ |
|
296 public Object clone() { |
|
297 try { |
|
298 SerialStruct ss = (SerialStruct) super.clone(); |
|
299 ss.attribs = Arrays.copyOf(attribs, attribs.length); |
|
300 return ss; |
|
301 } catch (CloneNotSupportedException ex) { |
|
302 // this shouldn't happen, since we are Cloneable |
|
303 throw new InternalError(); |
|
304 } |
|
305 |
|
306 } |
|
307 |
|
308 /** |
|
309 * readObject is called to restore the state of the {@code SerialStruct} from |
|
310 * a stream. |
|
311 */ |
|
312 private void readObject(ObjectInputStream s) |
|
313 throws IOException, ClassNotFoundException { |
|
314 |
|
315 ObjectInputStream.GetField fields = s.readFields(); |
|
316 Object[] tmp = (Object[])fields.get("attribs", null); |
|
317 attribs = tmp == null ? null : tmp.clone(); |
|
318 SQLTypeName = (String)fields.get("SQLTypeName", null); |
|
319 } |
|
320 |
|
321 /** |
|
322 * writeObject is called to save the state of the {@code SerialStruct} |
|
323 * to a stream. |
|
324 */ |
|
325 private void writeObject(ObjectOutputStream s) |
|
326 throws IOException, ClassNotFoundException { |
|
327 |
|
328 ObjectOutputStream.PutField fields = s.putFields(); |
|
329 fields.put("attribs", attribs); |
|
330 fields.put("SQLTypeName", SQLTypeName); |
|
331 s.writeFields(); |
|
332 } |
|
333 |
|
334 /** |
253 * The identifier that assists in the serialization of this |
335 * The identifier that assists in the serialization of this |
254 * <code>SerialStruct</code> object. |
336 * <code>SerialStruct</code> object. |
255 */ |
337 */ |
256 static final long serialVersionUID = -8322445504027483372L; |
338 static final long serialVersionUID = -8322445504027483372L; |
257 } |
339 } |