01: package com.mockrunner.mock.jdbc;
02:
03: import java.sql.Ref;
04: import java.sql.SQLException;
05: import java.util.Map;
06:
07: import com.mockrunner.base.NestedApplicationException;
08:
09: /**
10: * Mock implementation of <code>Ref</code>.
11: */
12: public class MockRef implements Ref, Cloneable {
13: private Object object;
14: private String baseTypeName;
15:
16: public MockRef(Object object) {
17: this .object = object;
18: baseTypeName = "";
19: }
20:
21: public String getBaseTypeName() throws SQLException {
22: return baseTypeName;
23: }
24:
25: /**
26: * Sets the base type name.
27: * @param baseTypeName the base type name
28: */
29: public void setBaseTypeName(String baseTypeName) {
30: this .baseTypeName = baseTypeName;
31: }
32:
33: public Object getObject(Map map) throws SQLException {
34: return object;
35: }
36:
37: public Object getObject() throws SQLException {
38: return object;
39: }
40:
41: public void setObject(Object object) throws SQLException {
42: this .object = object;
43: }
44:
45: public boolean equals(Object obj) {
46: if (null == obj)
47: return false;
48: if (!obj.getClass().equals(this .getClass()))
49: return false;
50: MockRef other = (MockRef) obj;
51: if (null != baseTypeName
52: && !baseTypeName.equals(other.baseTypeName))
53: return false;
54: if (null != other.baseTypeName
55: && !other.baseTypeName.equals(baseTypeName))
56: return false;
57: if (null == object && null == other.object)
58: return true;
59: if (null == object || null == other.object)
60: return false;
61: return object.equals(other.object);
62: }
63:
64: public int hashCode() {
65: int hashCode = 0;
66: if (null != baseTypeName)
67: hashCode = (31 * hashCode) + baseTypeName.hashCode();
68: if (null != object)
69: hashCode = (31 * hashCode) + object.hashCode();
70: return hashCode;
71: }
72:
73: public String toString() {
74: return "Ref data: " + object.toString();
75: }
76:
77: public Object clone() {
78: try {
79: return (MockRef) super .clone();
80: } catch (CloneNotSupportedException exc) {
81: throw new NestedApplicationException(exc);
82: }
83: }
84: }
|