/*
 * @(#)SQLInput.java	1.8 98/05/19
 * 
 * Copyright 1998 by Sun Microsystems, Inc.,
 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Sun Microsystems, Inc. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Sun.
 */

package java.sql;
 
/**
 * JDBC 2.0
 *
 * A SQLInput stream contains a stream of values that represent an SQL
 * structured or distinct type instance.
 */

public interface SQLInput {
  

  //================================================================
  // Methods for reading attributes from the stream of SQL data.
  // These methods correspond to the column-accessor methods of
  // java.sql.ResultSet.
  //================================================================

  /**
   * Read the next attribute in the stream as a Java String.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  String readString() throws SQLException;

  /**
   * Read the next attribute in the stream as a Java boolean.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  boolean readBoolean() throws SQLException;

  /**
   * Read the next attribute in the stream as a Java byte.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  byte readByte() throws SQLException;

  /**
   * Read the next attribute in the stream as a Java short.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  short readShort() throws SQLException;

  /**
   * Read the next attribute in the stream as a Java int.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  int readInt() throws SQLException;

  /**
   * Read the next attribute in the stream as a Java long.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  long readLong() throws SQLException;

  /**
   * Read the next attribute in the stream as a Java float.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  float readFloat() throws SQLException;

  /**
   * Read the next attribute in the stream as a Java double.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  double readDouble() throws SQLException;

  /**
   * Read the next attribute in the stream as a java.math.BigDecimal object.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  java.math.BigDecimal readBigDecimal() throws SQLException;

  /**
   * Read the next attribute in the stream as an array of bytes.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  byte[] readBytes() throws SQLException;

  /**
   * Read the next attribute in the stream as a java.sql.Date object.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  java.sql.Date readDate() throws SQLException;

  /**
   * Read the next attribute in the stream as a java.sql.Time object.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  java.sql.Time readTime() throws SQLException;

  /**
   * Read the next attribute in the stream as a java.sql.Timestamp object.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  java.sql.Timestamp readTimestamp() throws SQLException;

  /**
   * Return the next attribute in the stream as a stream of Unicode characters.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  java.io.Reader readCharacterStream() throws SQLException;

  /**
   * Return the next attribute in the stream as a stream of ASCII characters.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  java.io.InputStream readAsciiStream() throws SQLException;

  /**
   * Return the next attribute in the stream as a stream of uninterpreted
   * bytes.
   *
   * @return the attribute; if the value is SQL NULL, return null.
   */
  java.io.InputStream readBinaryStream() throws SQLException;
  
  //================================================================
  // Methods for reading items of SQL user-defined types from the stream.
  //================================================================

  /**
   * Return the datum at the head of the stream as a Java object.  The 
   * actual type of the object returned is determined by the default type
   * mapping, and any customizations present in this stream's type map.
   *
   * A type map is registered with the stream by the JDBC driver before the
   * stream is passed to the application.
   *
   * When the datum at the head of the stream is an SQL NULL, 
   * the method returns null.  If the datum is an SQL structured or distinct
   * type, it determines the SQL type of the datum at the head of the stream, 
   * constructs an object of the appropriate class, and calls method 
   * SQLData.readSQL on that object, which reads additional data from the 
   * stream, using the protocol described for SQLData.readSQL.
   *
   */
  Object readObject() throws SQLException;

  /**
   * Read a REF(&lt;structured-type&gt;) from the stream.
   *
   * @return an object representing data of an SQL REF Type
   */
  Ref readRef() throws SQLException;

  /**
   * Read a BLOB from the stream.
   *
   * @return an object representing a BLOB
   */
  Blob readBlob() throws SQLException;

  /**
   * Read a CLOB from the stream.
   *
   * @return an object representing  a CLOB
   */
  Clob readClob() throws SQLException;

  /**
   * Read an array from the stream.
   *
   * @return an object representing an SQL array
   */
  Array readArray() throws SQLException;

  /**
   * @return true iff the most recently gotten SQL value was null.
   * 
   */
  boolean wasNull() throws SQLException;

}
