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

Print this page




 146             lastValueWasNull = attrib[idx] == null;
 147             return attrib[idx];
 148         }
 149     }
 150 
 151 
 152     //================================================================
 153     // Methods for reading attributes from the stream of SQL data.
 154     // These methods correspond to the column-accessor methods of
 155     // java.sql.ResultSet.
 156     //================================================================
 157 
 158     /**
 159      * Retrieves the next attribute in this <code>SQLInputImpl</code> object as
 160      * a <code>String</code> in the Java programming language.
 161      * <p>
 162      * This method does not perform type-safe checking to determine if the
 163      * returned type is the expected type; this responsibility is delegated
 164      * to the UDT mapping as defined by a <code>SQLData</code>
 165      * implementation.
 166      * <p>
 167      * @return the next attribute in this <code>SQLInputImpl</code> object;
 168      *     if the value is <code>SQL NULL</code>, return <code>null</code>
 169      * @throws SQLException if the read position is located at an invalid
 170      *     position or if there are no further values in the stream.
 171      */
 172     public String readString() throws SQLException {
 173         return  (String)getNextAttribute();
 174     }
 175 
 176     /**
 177      * Retrieves the next attribute in this <code>SQLInputImpl</code> object as
 178      * a <code>boolean</code> in the Java programming language.
 179      * <p>
 180      * This method does not perform type-safe checking to determine if the
 181      * returned type is the expected type; this responsibility is delegated
 182      * to the UDT mapping as defined by a <code>SQLData</code>
 183      * implementation.
 184      * <p>
 185      * @return the next attribute in this <code>SQLInputImpl</code> object;
 186      *     if the value is <code>SQL NULL</code>, return <code>null</code>
 187      * @throws SQLException if the read position is located at an invalid
 188      *     position or if there are no further values in the stream.
 189      */
 190     public boolean readBoolean() throws SQLException {
 191         Boolean attrib = (Boolean)getNextAttribute();
 192         return  (attrib == null) ? false : attrib.booleanValue();
 193     }
 194 
 195     /**
 196      * Retrieves the next attribute in this <code>SQLInputImpl</code> object as
 197      * a <code>byte</code> in the Java programming language.
 198      * <p>
 199      * This method does not perform type-safe checking to determine if the
 200      * returned type is the expected type; this responsibility is delegated
 201      * to the UDT mapping as defined by a <code>SQLData</code>
 202      * implementation.
 203      * <p>
 204      * @return the next attribute in this <code>SQLInputImpl</code> object;
 205      *     if the value is <code>SQL NULL</code>, return <code>null</code>
 206      * @throws SQLException if the read position is located at an invalid
 207      *     position or if there are no further values in the stream
 208      */
 209     public byte readByte() throws SQLException {
 210         Byte attrib = (Byte)getNextAttribute();
 211         return  (attrib == null) ? 0 : attrib.byteValue();
 212     }
 213 
 214     /**
 215      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 216      * as a <code>short</code> in the Java programming language.
 217      * <P>
 218      * This method does not perform type-safe checking to determine if the
 219      * returned type is the expected type; this responsibility is delegated
 220      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 221      * <P>
 222      * @return the next attribute in this <code>SQLInputImpl</code> object;
 223      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 224      * @throws SQLException if the read position is located at an invalid
 225      *       position or if there are no more values in the stream
 226      */
 227     public short readShort() throws SQLException {
 228         Short attrib = (Short)getNextAttribute();
 229         return (attrib == null) ? 0 : attrib.shortValue();
 230     }
 231 
 232     /**
 233      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 234      * as an <code>int</code> in the Java programming language.
 235      * <P>
 236      * This method does not perform type-safe checking to determine if the
 237      * returned type is the expected type; this responsibility is delegated
 238      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 239      * <P>
 240      * @return the next attribute in this <code>SQLInputImpl</code> object;
 241      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 242      * @throws SQLException if the read position is located at an invalid
 243      *       position or if there are no more values in the stream
 244      */
 245     public int readInt() throws SQLException {
 246         Integer attrib = (Integer)getNextAttribute();
 247         return (attrib == null) ? 0 : attrib.intValue();
 248     }
 249 
 250     /**
 251      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 252      * as a <code>long</code> in the Java programming language.
 253      * <P>
 254      * This method does not perform type-safe checking to determine if the
 255      * returned type is the expected type; this responsibility is delegated
 256      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 257      * <P>
 258      * @return the next attribute in this <code>SQLInputImpl</code> object;
 259      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 260      * @throws SQLException if the read position is located at an invalid
 261      *       position or if there are no more values in the stream
 262      */
 263     public long readLong() throws SQLException {
 264         Long attrib = (Long)getNextAttribute();
 265         return (attrib == null) ? 0 : attrib.longValue();
 266     }
 267 
 268     /**
 269      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 270      * as a <code>float</code> in the Java programming language.
 271      * <P>
 272      * This method does not perform type-safe checking to determine if the
 273      * returned type is the expected type; this responsibility is delegated
 274      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 275      * <P>
 276      * @return the next attribute in this <code>SQLInputImpl</code> object;
 277      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 278      * @throws SQLException if the read position is located at an invalid
 279      *       position or if there are no more values in the stream
 280      */
 281     public float readFloat() throws SQLException {
 282         Float attrib = (Float)getNextAttribute();
 283         return (attrib == null) ? 0 : attrib.floatValue();
 284     }
 285 
 286     /**
 287      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 288      * as a <code>double</code> in the Java programming language.
 289      * <P>
 290      * This method does not perform type-safe checking to determine if the
 291      * returned type is the expected type; this responsibility is delegated
 292      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 293      * <P>
 294      * @return the next attribute in this <code>SQLInputImpl</code> object;
 295      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 296      * @throws SQLException if the read position is located at an invalid
 297      *       position or if there are no more values in the stream
 298      */
 299     public double readDouble() throws SQLException {
 300         Double attrib = (Double)getNextAttribute();
 301         return (attrib == null)  ? 0 :  attrib.doubleValue();
 302     }
 303 
 304     /**
 305      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 306      * as a <code>java.math.BigDecimal</code>.
 307      * <P>
 308      * This method does not perform type-safe checking to determine if the
 309      * returned type is the expected type; this responsibility is delegated
 310      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 311      * <P>
 312      * @return the next attribute in this <code>SQLInputImpl</code> object;
 313      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 314      * @throws SQLException if the read position is located at an invalid
 315      *       position or if there are no more values in the stream
 316      */
 317     public java.math.BigDecimal readBigDecimal() throws SQLException {
 318         return (java.math.BigDecimal)getNextAttribute();
 319     }
 320 
 321     /**
 322      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 323      * as an array of bytes.
 324      * <p>
 325      * This method does not perform type-safe checking to determine if the
 326      * returned type is the expected type; this responsibility is delegated
 327      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 328      * <P>
 329      * @return the next attribute in this <code>SQLInputImpl</code> object;
 330      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 331      * @throws SQLException if the read position is located at an invalid
 332      *       position or if there are no more values in the stream
 333      */
 334     public byte[] readBytes() throws SQLException {
 335         return (byte[])getNextAttribute();
 336     }
 337 
 338     /**
 339      * Retrieves the next attribute in this <code>SQLInputImpl</code> as
 340      * a <code>java.sql.Date</code> object.
 341      * <P>
 342      * This method does not perform type-safe checking to determine if the
 343      * returned type is the expected type; this responsibility is delegated
 344      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 345      * <P>
 346      * @return the next attribute in this <code>SQLInputImpl</code> object;
 347      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 348      * @throws SQLException if the read position is located at an invalid
 349      *       position or if there are no more values in the stream
 350      */
 351     public java.sql.Date readDate() throws SQLException {
 352         return (java.sql.Date)getNextAttribute();
 353     }
 354 
 355     /**
 356      * Retrieves the next attribute in this <code>SQLInputImpl</code> object as
 357      * a <code>java.sql.Time</code> object.
 358      * <P>
 359      * This method does not perform type-safe checking to determine if the
 360      * returned type is the expected type as this responsibility is delegated
 361      * to the UDT mapping as implemented by a <code>SQLData</code>
 362      * implementation.
 363      *
 364      * @return the attribute; if the value is <code>SQL NULL</code>, return
 365      * <code>null</code>




 146             lastValueWasNull = attrib[idx] == null;
 147             return attrib[idx];
 148         }
 149     }
 150 
 151 
 152     //================================================================
 153     // Methods for reading attributes from the stream of SQL data.
 154     // These methods correspond to the column-accessor methods of
 155     // java.sql.ResultSet.
 156     //================================================================
 157 
 158     /**
 159      * Retrieves the next attribute in this <code>SQLInputImpl</code> object as
 160      * a <code>String</code> in the Java programming language.
 161      * <p>
 162      * This method does not perform type-safe checking to determine if the
 163      * returned type is the expected type; this responsibility is delegated
 164      * to the UDT mapping as defined by a <code>SQLData</code>
 165      * implementation.
 166      *
 167      * @return the next attribute in this <code>SQLInputImpl</code> object;
 168      *     if the value is <code>SQL NULL</code>, return <code>null</code>
 169      * @throws SQLException if the read position is located at an invalid
 170      *     position or if there are no further values in the stream.
 171      */
 172     public String readString() throws SQLException {
 173         return  (String)getNextAttribute();
 174     }
 175 
 176     /**
 177      * Retrieves the next attribute in this <code>SQLInputImpl</code> object as
 178      * a <code>boolean</code> in the Java programming language.
 179      * <p>
 180      * This method does not perform type-safe checking to determine if the
 181      * returned type is the expected type; this responsibility is delegated
 182      * to the UDT mapping as defined by a <code>SQLData</code>
 183      * implementation.
 184      *
 185      * @return the next attribute in this <code>SQLInputImpl</code> object;
 186      *     if the value is <code>SQL NULL</code>, return <code>null</code>
 187      * @throws SQLException if the read position is located at an invalid
 188      *     position or if there are no further values in the stream.
 189      */
 190     public boolean readBoolean() throws SQLException {
 191         Boolean attrib = (Boolean)getNextAttribute();
 192         return  (attrib == null) ? false : attrib.booleanValue();
 193     }
 194 
 195     /**
 196      * Retrieves the next attribute in this <code>SQLInputImpl</code> object as
 197      * a <code>byte</code> in the Java programming language.
 198      * <p>
 199      * This method does not perform type-safe checking to determine if the
 200      * returned type is the expected type; this responsibility is delegated
 201      * to the UDT mapping as defined by a <code>SQLData</code>
 202      * implementation.
 203      *
 204      * @return the next attribute in this <code>SQLInputImpl</code> object;
 205      *     if the value is <code>SQL NULL</code>, return <code>null</code>
 206      * @throws SQLException if the read position is located at an invalid
 207      *     position or if there are no further values in the stream
 208      */
 209     public byte readByte() throws SQLException {
 210         Byte attrib = (Byte)getNextAttribute();
 211         return  (attrib == null) ? 0 : attrib.byteValue();
 212     }
 213 
 214     /**
 215      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 216      * as a <code>short</code> in the Java programming language.
 217      * <P>
 218      * This method does not perform type-safe checking to determine if the
 219      * returned type is the expected type; this responsibility is delegated
 220      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 221      *
 222      * @return the next attribute in this <code>SQLInputImpl</code> object;
 223      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 224      * @throws SQLException if the read position is located at an invalid
 225      *       position or if there are no more values in the stream
 226      */
 227     public short readShort() throws SQLException {
 228         Short attrib = (Short)getNextAttribute();
 229         return (attrib == null) ? 0 : attrib.shortValue();
 230     }
 231 
 232     /**
 233      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 234      * as an <code>int</code> in the Java programming language.
 235      * <P>
 236      * This method does not perform type-safe checking to determine if the
 237      * returned type is the expected type; this responsibility is delegated
 238      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 239      *
 240      * @return the next attribute in this <code>SQLInputImpl</code> object;
 241      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 242      * @throws SQLException if the read position is located at an invalid
 243      *       position or if there are no more values in the stream
 244      */
 245     public int readInt() throws SQLException {
 246         Integer attrib = (Integer)getNextAttribute();
 247         return (attrib == null) ? 0 : attrib.intValue();
 248     }
 249 
 250     /**
 251      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 252      * as a <code>long</code> in the Java programming language.
 253      * <P>
 254      * This method does not perform type-safe checking to determine if the
 255      * returned type is the expected type; this responsibility is delegated
 256      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 257      *
 258      * @return the next attribute in this <code>SQLInputImpl</code> object;
 259      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 260      * @throws SQLException if the read position is located at an invalid
 261      *       position or if there are no more values in the stream
 262      */
 263     public long readLong() throws SQLException {
 264         Long attrib = (Long)getNextAttribute();
 265         return (attrib == null) ? 0 : attrib.longValue();
 266     }
 267 
 268     /**
 269      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 270      * as a <code>float</code> in the Java programming language.
 271      * <P>
 272      * This method does not perform type-safe checking to determine if the
 273      * returned type is the expected type; this responsibility is delegated
 274      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 275      *
 276      * @return the next attribute in this <code>SQLInputImpl</code> object;
 277      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 278      * @throws SQLException if the read position is located at an invalid
 279      *       position or if there are no more values in the stream
 280      */
 281     public float readFloat() throws SQLException {
 282         Float attrib = (Float)getNextAttribute();
 283         return (attrib == null) ? 0 : attrib.floatValue();
 284     }
 285 
 286     /**
 287      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 288      * as a <code>double</code> in the Java programming language.
 289      * <P>
 290      * This method does not perform type-safe checking to determine if the
 291      * returned type is the expected type; this responsibility is delegated
 292      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 293      *
 294      * @return the next attribute in this <code>SQLInputImpl</code> object;
 295      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 296      * @throws SQLException if the read position is located at an invalid
 297      *       position or if there are no more values in the stream
 298      */
 299     public double readDouble() throws SQLException {
 300         Double attrib = (Double)getNextAttribute();
 301         return (attrib == null)  ? 0 :  attrib.doubleValue();
 302     }
 303 
 304     /**
 305      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 306      * as a <code>java.math.BigDecimal</code>.
 307      * <P>
 308      * This method does not perform type-safe checking to determine if the
 309      * returned type is the expected type; this responsibility is delegated
 310      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 311      *
 312      * @return the next attribute in this <code>SQLInputImpl</code> object;
 313      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 314      * @throws SQLException if the read position is located at an invalid
 315      *       position or if there are no more values in the stream
 316      */
 317     public java.math.BigDecimal readBigDecimal() throws SQLException {
 318         return (java.math.BigDecimal)getNextAttribute();
 319     }
 320 
 321     /**
 322      * Retrieves the next attribute in this <code>SQLInputImpl</code> object
 323      * as an array of bytes.
 324      * <p>
 325      * This method does not perform type-safe checking to determine if the
 326      * returned type is the expected type; this responsibility is delegated
 327      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 328      *
 329      * @return the next attribute in this <code>SQLInputImpl</code> object;
 330      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 331      * @throws SQLException if the read position is located at an invalid
 332      *       position or if there are no more values in the stream
 333      */
 334     public byte[] readBytes() throws SQLException {
 335         return (byte[])getNextAttribute();
 336     }
 337 
 338     /**
 339      * Retrieves the next attribute in this <code>SQLInputImpl</code> as
 340      * a <code>java.sql.Date</code> object.
 341      * <P>
 342      * This method does not perform type-safe checking to determine if the
 343      * returned type is the expected type; this responsibility is delegated
 344      * to the UDT mapping as defined by a <code>SQLData</code> implementation.
 345      *
 346      * @return the next attribute in this <code>SQLInputImpl</code> object;
 347      *       if the value is <code>SQL NULL</code>, return <code>null</code>
 348      * @throws SQLException if the read position is located at an invalid
 349      *       position or if there are no more values in the stream
 350      */
 351     public java.sql.Date readDate() throws SQLException {
 352         return (java.sql.Date)getNextAttribute();
 353     }
 354 
 355     /**
 356      * Retrieves the next attribute in this <code>SQLInputImpl</code> object as
 357      * a <code>java.sql.Time</code> object.
 358      * <P>
 359      * This method does not perform type-safe checking to determine if the
 360      * returned type is the expected type as this responsibility is delegated
 361      * to the UDT mapping as implemented by a <code>SQLData</code>
 362      * implementation.
 363      *
 364      * @return the attribute; if the value is <code>SQL NULL</code>, return
 365      * <code>null</code>