< prev index next >

src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SQLInputImpl.java

Print this page




 461      * method then calls the appropriate <code>SQLInputImpl.readXXX</code>
 462      * methods to retrieve the attribute values from the stream.
 463      *
 464      * @return the value at the head of the stream as an <code>Object</code>
 465      *         in the Java programming language; <code>null</code> if
 466      *         the value is SQL <code>NULL</code>
 467      * @throws SQLException if the read position is located at an invalid
 468      * position; or if there are no further values in the stream.
 469      */
 470     public Object readObject() throws SQLException {
 471         Object attrib = getNextAttribute();
 472         if (attrib instanceof Struct) {
 473             Struct s = (Struct)attrib;
 474             // look up the class in the map
 475             Class<?> c = map.get(s.getSQLTypeName());
 476             if (c != null) {
 477                 // create new instance of the class
 478                 SQLData obj = null;
 479                 try {
 480                     ReflectUtil.checkPackageAccess(c);
 481                     obj = (SQLData)c.newInstance();


 482                 } catch (Exception ex) {
 483                     throw new SQLException("Unable to Instantiate: ", ex);
 484                 }
 485                 // get the attributes from the struct
 486                 Object attribs[] = s.getAttributes(map);
 487                 // create the SQLInput "stream"
 488                 SQLInputImpl sqlInput = new SQLInputImpl(attribs, map);
 489                 // read the values...
 490                 obj.readSQL(sqlInput, s.getSQLTypeName());
 491                 return obj;
 492             }
 493         }
 494         return attrib;
 495     }
 496 
 497     /**
 498      * Retrieves the value at the head of this <code>SQLInputImpl</code> object
 499      * as a <code>Ref</code> object in the Java programming language.
 500      *
 501      * @return a <code>Ref</code> object representing the SQL




 461      * method then calls the appropriate <code>SQLInputImpl.readXXX</code>
 462      * methods to retrieve the attribute values from the stream.
 463      *
 464      * @return the value at the head of the stream as an <code>Object</code>
 465      *         in the Java programming language; <code>null</code> if
 466      *         the value is SQL <code>NULL</code>
 467      * @throws SQLException if the read position is located at an invalid
 468      * position; or if there are no further values in the stream.
 469      */
 470     public Object readObject() throws SQLException {
 471         Object attrib = getNextAttribute();
 472         if (attrib instanceof Struct) {
 473             Struct s = (Struct)attrib;
 474             // look up the class in the map
 475             Class<?> c = map.get(s.getSQLTypeName());
 476             if (c != null) {
 477                 // create new instance of the class
 478                 SQLData obj = null;
 479                 try {
 480                     ReflectUtil.checkPackageAccess(c);
 481                     @SuppressWarnings("deprecation")
 482                     Object tmp = c.newInstance();
 483                     obj = (SQLData)tmp;
 484                 } catch (Exception ex) {
 485                     throw new SQLException("Unable to Instantiate: ", ex);
 486                 }
 487                 // get the attributes from the struct
 488                 Object attribs[] = s.getAttributes(map);
 489                 // create the SQLInput "stream"
 490                 SQLInputImpl sqlInput = new SQLInputImpl(attribs, map);
 491                 // read the values...
 492                 obj.readSQL(sqlInput, s.getSQLTypeName());
 493                 return obj;
 494             }
 495         }
 496         return attrib;
 497     }
 498 
 499     /**
 500      * Retrieves the value at the head of this <code>SQLInputImpl</code> object
 501      * as a <code>Ref</code> object in the Java programming language.
 502      *
 503      * @return a <code>Ref</code> object representing the SQL


< prev index next >