1 7 8 package javax.sql.rowset.serial; 9 10 import java.sql.*; 11 import java.io.*; 12 import java.util.*; 13 14 22 public class SerialRef implements Ref, Serializable, Cloneable { 23 24 28 private String baseTypeName; 29 30 33 private Object object; 34 35 38 private Ref reference; 39 40 51 public SerialRef(Ref ref) throws SerialException , SQLException { 52 if (ref == null) { 53 throw new SQLException("Cannot instantiate a SerialRef object " + 54 "with a null Ref object"); 55 } 56 reference = ref; 57 object = ref; 58 if (ref.getBaseTypeName() == null) { 59 throw new SQLException("Cannot instantiate a SerialRef object " + 60 "that returns a null base type name"); 61 } else { 62 baseTypeName = new String (ref.getBaseTypeName()); 63 } 64 } 65 66 72 public String getBaseTypeName() throws SerialException { 73 return baseTypeName; 74 } 75 76 91 public Object getObject(java.util.Map <String ,Class <?>> map) 92 throws SerialException 93 { 94 map = new Hashtable(map); 95 if (!object.equals(null)) { 96 return map.get(object); 97 } else { 98 throw new SerialException ("The object is not set"); 99 } 100 } 101 102 110 public Object getObject() throws SerialException { 111 112 if (reference != null) { 113 try { 114 return reference.getObject(); 115 } catch (SQLException e) { 116 throw new SerialException ("SQLException: " + e.getMessage()); 117 } 118 } 119 120 if (object != null) { 121 return object; 122 } 123 124 125 throw new SerialException ("The object is not set"); 126 127 } 128 129 138 public void setObject(Object obj) throws SerialException { 139 try { 140 reference.setObject(obj); 141 } catch (SQLException e) { 142 throw new SerialException ("SQLException: " + e.getMessage()); 143 } 144 object = obj; 145 } 146 147 151 static final long serialVersionUID = -4727123500609662274L; 152 153 154 } 155 156 157 158 | Popular Tags |