2362N/A * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * An input stream used for custom mapping user-defined types (UDTs). 0N/A * An <code>SQLInputImpl</code> object is an input stream that contains a 0N/A * stream of values that are the attributes of a UDT. 0N/A * This class is used by the driver behind the scenes when the method 0N/A * <code>getObject</code> is called on an SQL structured or distinct type 0N/A * that has a custom mapping; a programmer never invokes 0N/A * <code>SQLInputImpl</code> methods directly. They are provided here as a 0N/A * convenience for those who write <code>RowSet</code> implementations. 0N/A * The <code>SQLInputImpl</code> class provides a set of 0N/A * reader methods analogous to the <code>ResultSet</code> getter 0N/A * methods. These methods make it possible to read the values in an 0N/A * <code>SQLInputImpl</code> object. 0N/A * The method <code>wasNull</code> is used to determine whether the 0N/A * the last value read was SQL <code>NULL</code>. 0N/A * <P>When the method <code>getObject</code> is called with an 0N/A * object of a class implementing the interface <code>SQLData</code>, 0N/A * the JDBC driver calls the method <code>SQLData.getSQLType</code> 0N/A * to determine the SQL type of the UDT being custom mapped. The driver 0N/A * creates an instance of <code>SQLInputImpl</code>, populating it with the 0N/A * attributes of the UDT. The driver then passes the input 0N/A * stream to the method <code>SQLData.readSQL</code>, which in turn 0N/A * calls the <code>SQLInputImpl</code> reader methods 0N/A * to read the attributes from the input stream. 0N/A * @see java.sql.SQLData 0N/A * <code>true</code> if the last value returned was <code>SQL NULL</code>; 0N/A * <code>false</code> otherwise. 0N/A * The current index into the array of SQL structured type attributes 0N/A * that will be read from this <code>SQLInputImpl</code> object and 0N/A * mapped to the fields of a class in the Java programming language. 0N/A * The array of attributes to be read from this stream. The order 0N/A * of the attributes is the same as the order in which they were 0N/A * listed in the SQL definition of the UDT. 0N/A * The type map to use when the method <code>readObject</code> 0N/A * is invoked. This is a <code>java.util.Map</code> object in which 0N/A * there may be zero or more entries. Each entry consists of the 0N/A * fully qualified name of a UDT (the value to be mapped) and the 0N/A * <code>Class</code> object for a class that implements 0N/A * <code>SQLData</code> (the Java class that defines how the UDT 0N/A * Creates an <code>SQLInputImpl</code> object initialized with the 0N/A * given array of attributes and the given type map. If any of the 0N/A * attributes is a UDT whose name is in an entry in the type map, 0N/A * the attribute will be mapped according to the corresponding 0N/A * <code>SQLData</code> implementation. 0N/A * @param attributes an array of <code>Object</code> instances in which 0N/A * each element is an attribute of a UDT. The order of the 0N/A * attributes in the array is the same order in which 0N/A * the attributes were defined in the UDT definition. 0N/A * @param map a <code>java.util.Map</code> object containing zero or more 0N/A * entries, with each entry consisting of 1) a <code>String</code> 0N/A * qualified name of the UDT and 2) the <code>Class</code> object 0N/A * for the <code>SQLData</code> implementation that defines how 0N/A * the UDT is to be mapped 0N/A * @throws SQLException if the <code>attributes</code> or the <code>map</code> 0N/A * is a <code>null</code> value 0N/A "object with null parameters");
0N/A // assign our local reference to the attribute stream 0N/A // init the index point before the head of the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object 0N/A * as an <code>Object</code> in the Java programming language. 0N/A * @return the next value in the input stream 0N/A * as an <code>Object</code> in the Java programming language 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no further values in the stream 0N/A //================================================================ 0N/A // Methods for reading attributes from the stream of SQL data. 0N/A // These methods correspond to the column-accessor methods of 0N/A // java.sql.ResultSet. 0N/A //================================================================ 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object as 0N/A * a <code>String</code> in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no further values in the stream. 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object as 0N/A * a <code>boolean</code> in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no further values in the stream. 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object as 0N/A * a <code>byte</code> in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no further values in the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object 0N/A * as a <code>short</code> in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> implementation. 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no more values in the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object 0N/A * as an <code>int</code> in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> implementation. 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no more values in the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object 0N/A * as a <code>long</code> in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> implementation. 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no more values in the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object 0N/A * as a <code>float</code> in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> implementation. 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no more values in the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object 0N/A * as a <code>double</code> in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> implementation. 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no more values in the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object 0N/A * as a <code>java.math.BigDecimal</code>. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> implementation. 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no more values in the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object 0N/A * as an array of bytes. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> implementation. 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no more values in the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> as 0N/A * a <code>java.sql.Date</code> object. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type; this responsibility is delegated 0N/A * to the UDT mapping as defined by a <code>SQLData</code> implementation. 0N/A * @return the next attribute in this <code>SQLInputImpl</code> object; 0N/A * if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position or if there are no more values in the stream 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object as 0N/A * a <code>java.sql.Time</code> object. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type as this responsibility is delegated 0N/A * to the UDT mapping as implemented by a <code>SQLData</code> 0N/A * @return the attribute; if the value is <code>SQL NULL</code>, return 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object as 0N/A * a <code>java.sql.Timestamp</code> object. 0N/A * @return the attribute; if the value is <code>SQL NULL</code>, return 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A * Retrieves the next attribute in this <code>SQLInputImpl</code> object 0N/A * as a stream of Unicode characters. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type as this responsibility is delegated 0N/A * to the UDT mapping as implemented by a <code>SQLData</code> 0N/A * @return the attribute; if the value is <code>SQL NULL</code>, return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A * Returns the next attribute in this <code>SQLInputImpl</code> object 0N/A * as a stream of ASCII characters. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type as this responsibility is delegated 0N/A * to the UDT mapping as implemented by a <code>SQLData</code> 0N/A * @return the attribute; if the value is <code>SQL NULL</code>, 0N/A * return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A * Returns the next attribute in this <code>SQLInputImpl</code> object 0N/A * as a stream of uninterpreted bytes. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type as this responsibility is delegated 0N/A * to the UDT mapping as implemented by a <code>SQLData</code> 0N/A * @return the attribute; if the value is <code>SQL NULL</code>, return 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A //================================================================ 0N/A // Methods for reading items of SQL user-defined types from the stream. 0N/A //================================================================ 0N/A * Retrieves the value at the head of this <code>SQLInputImpl</code> 0N/A * object as an <code>Object</code> in the Java programming language. The 0N/A * actual type of the object returned is determined by the default 0N/A * mapping of SQL types to types in the Java programming language unless 0N/A * there is a custom mapping, in which case the type of the object 0N/A * returned is determined by this stream's type map. 0N/A * The JDBC technology-enabled driver registers a type map with the stream 0N/A * before passing the stream to the application. 0N/A * When the datum at the head of the stream is an SQL <code>NULL</code>, 0N/A * this method returns <code>null</code>. If the datum is an SQL 0N/A * structured or distinct type with a custom mapping, this method 0N/A * determines the SQL type of the datum at the head of the stream, 0N/A * constructs an object of the appropriate class, and calls the method 0N/A * <code>SQLData.readSQL</code> on that object. The <code>readSQL</code> 0N/A * method then calls the appropriate <code>SQLInputImpl.readXXX</code> 0N/A * methods to retrieve the attribute values from the stream. 0N/A * @return the value at the head of the stream as an <code>Object</code> 0N/A * in the Java programming language; <code>null</code> if 0N/A * the value is SQL <code>NULL</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A // look up the class in the map 0N/A // create new instance of the class 0N/A // get the attributes from the struct 0N/A // create the SQLInput "stream" 0N/A // read the values... 0N/A * Retrieves the value at the head of this <code>SQLInputImpl</code> object 0N/A * as a <code>Ref</code> object in the Java programming language. 0N/A * @return a <code>Ref</code> object representing the SQL 0N/A * <code>REF</code> value at the head of the stream; if the value 0N/A * is <code>SQL NULL</code> return <code>null</code> 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A * Retrieves the <code>BLOB</code> value at the head of this 0N/A * <code>SQLInputImpl</code> object as a <code>Blob</code> object 0N/A * in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type as this responsibility is delegated 0N/A * to the UDT mapping as implemented by a <code>SQLData</code> 0N/A * @return a <code>Blob</code> object representing the SQL 0N/A * <code>BLOB</code> value at the head of this stream; 0N/A * if the value is <code>SQL NULL</code>, return 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A * Retrieves the <code>CLOB</code> value at the head of this 0N/A * <code>SQLInputImpl</code> object as a <code>Clob</code> object 0N/A * in the Java programming language. 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type as this responsibility is delegated 0N/A * to the UDT mapping as implemented by a <code>SQLData</code> 0N/A * @return a <code>Clob</code> object representing the SQL 0N/A * <code>CLOB</code> value at the head of the stream; 0N/A * if the value is <code>SQL NULL</code>, return 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A * Reads an SQL <code>ARRAY</code> value from the stream and 0N/A * returns it as an <code>Array</code> object in the Java programming 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type as this responsibility is delegated 0N/A * to the UDT mapping as implemented by a <code>SQLData</code> 0N/A * @return an <code>Array</code> object representing the SQL 0N/A * <code>ARRAY</code> value at the head of the stream; * 0N/A * if the value is <code>SQL NULL</code>, return 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A * Ascertains whether the last value read from this 0N/A * <code>SQLInputImpl</code> object was <code>null</code>. 0N/A * @return <code>true</code> if the SQL value read most recently was 0N/A * <code>null</code>; otherwise, <code>false</code>; by default it 0N/A * @throws SQLException if an error occurs determining the last value 0N/A * read was a <code>null</code> value or not; 0N/A * Reads an SQL <code>DATALINK</code> value from the stream and 0N/A * returns it as an <code>URL</code> object in the Java programming 0N/A * This method does not perform type-safe checking to determine if the 0N/A * returned type is the expected type as this responsibility is delegated 0N/A * to the UDT mapping as implemented by a <code>SQLData</code> 0N/A * @return an <code>URL</code> object representing the SQL 0N/A * <code>DATALINK</code> value at the head of the stream; * 0N/A * if the value is <code>SQL NULL</code>, return 0N/A * @throws SQLException if the read position is located at an invalid 0N/A * position; or if there are no further values in the stream. 0N/A //---------------------------- JDBC 4.0 ------------------------- 0N/A * Reads an SQL <code>NCLOB</code> value from the stream and returns it as a 0N/A * <code>Clob</code> object in the Java programming language. 0N/A * @return a <code>NClob</code> object representing data of the SQL <code>NCLOB</code> value 0N/A * at the head of the stream; <code>null</code> if the value read is 0N/A * SQL <code>NULL</code> 0N/A * @exception SQLException if a database access error occurs 0N/A * Reads the next attribute in the stream and returns it as a <code>String</code> 0N/A * in the Java programming language. It is intended for use when 0N/A * accessing <code>NCHAR</code>,<code>NVARCHAR</code> 0N/A * and <code>LONGNVARCHAR</code> columns. 0N/A * @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code> 0N/A * @exception SQLException if a database access error occurs 0N/A * Reads an SQL <code>XML</code> value from the stream and returns it as a 0N/A * <code>SQLXML</code> object in the Java programming language. 0N/A * @return a <code>SQLXML</code> object representing data of the SQL <code>XML</code> value 0N/A * at the head of the stream; <code>null</code> if the value read is 0N/A * SQL <code>NULL</code> 0N/A * @exception SQLException if a database access error occurs 0N/A * Reads an SQL <code>ROWID</code> value from the stream and returns it as a 0N/A * <code>RowId</code> object in the Java programming language. 0N/A * @return a <code>RowId</code> object representing data of the SQL <code>ROWID</code> value 0N/A * at the head of the stream; <code>null</code> if the value read is 0N/A * SQL <code>NULL</code> 0N/A * @exception SQLException if a database access error occurs