--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java Mon Nov 05 12:51:14 2012 -0500
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java Tue Nov 06 14:59:22 2012 -0500
@@ -250,6 +250,88 @@
}
/**
+ * Compares this SerialStruct to the specified object. The result is
+ * {@code true} if and only if the argument is not {@code null} and is a
+ * {@code SerialStruct} object whose attributes are identical to this
+ * object's attributes
+ *
+ * @param obj The object to compare this {@code SerialStruct} against
+ *
+ * @return {@code true} if the given object represents a {@code SerialStruct}
+ * equivalent to this SerialStruct, {@code false} otherwise
+ *
+ */
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SerialStruct) {
+ SerialStruct ss = (SerialStruct)obj;
+ return SQLTypeName.equals(ss.SQLTypeName) &&
+ Arrays.equals(attribs, ss.attribs);
+ }
+ return false;
+ }
+
+ /**
+ * Returns a hash code for this {@code SerialStruct}. The hash code for a
+ * {@code SerialStruct} object is computed using the hash codes
+ * of the attributes of the {@code SerialStruct} object and its
+ * {@code SQLTypeName}
+ *
+ * @return a hash code value for this object.
+ */
+ public int hashCode() {
+ return ((31 + Arrays.hashCode(attribs)) * 31) * 31
+ + SQLTypeName.hashCode();
+ }
+
+ /**
+ * Returns a clone of this {@code SerialStruct}. The copy will contain a
+ * reference to a clone of the underlying attribs array, not a reference
+ * to the original underlying attribs array of this {@code SerialStruct} object.
+ *
+ * @return a clone of this SerialStruct
+ */
+ public Object clone() {
+ try {
+ SerialStruct ss = (SerialStruct) super.clone();
+ ss.attribs = Arrays.copyOf(attribs, attribs.length);
+ return ss;
+ } catch (CloneNotSupportedException ex) {
+ // this shouldn't happen, since we are Cloneable
+ throw new InternalError();
+ }
+
+ }
+
+ /**
+ * readObject is called to restore the state of the {@code SerialStruct} from
+ * a stream.
+ */
+ private void readObject(ObjectInputStream s)
+ throws IOException, ClassNotFoundException {
+
+ ObjectInputStream.GetField fields = s.readFields();
+ Object[] tmp = (Object[])fields.get("attribs", null);
+ attribs = tmp == null ? null : tmp.clone();
+ SQLTypeName = (String)fields.get("SQLTypeName", null);
+ }
+
+ /**
+ * writeObject is called to save the state of the {@code SerialStruct}
+ * to a stream.
+ */
+ private void writeObject(ObjectOutputStream s)
+ throws IOException, ClassNotFoundException {
+
+ ObjectOutputStream.PutField fields = s.putFields();
+ fields.put("attribs", attribs);
+ fields.put("SQLTypeName", SQLTypeName);
+ s.writeFields();
+ }
+
+ /**
* The identifier that assists in the serialization of this
* <code>SerialStruct</code> object.
*/