/*
 * @(#)SQLOutput.java	1.7 98/05/08
 * 
 * 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
 *
 * When an object of a class implementing interface
 * <code>SqlData</code> is passed as an argument to an SQL statement, the
 * JDBC driver calls its <code>getSqlType</code> to determine kind of SQL
 * datum being passed to the database.  It then calls its method
 * <code>writeSql</code> with an argument of class <code>SqlOutput</code>
 * which implements a <i>SQL data stream</i> that is being written to the
 * database.  Method <code>writeSql</code> writes data from the object to
 * that SQL data stream as the representation of an SQL complex type.
 */

 public interface SQLOutput {

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

  /**
   * Write the next attribute to the stream as a Java String.
   *
   * @param x the value to pass to the database.
   */
  void writeString(String x) throws SQLException;

  /**
   * Write the next attribute to the stream as a Java boolean.
   *
   * @param x the value to pass to the database.
   */
  void writeBoolean(boolean x) throws SQLException;

  /**
   * Write the next attribute to the stream as a Java byte.
   *
   * @param x the value to pass to the database.
   */
  void writeByte(byte x) throws SQLException;

  /**
   * Write the next attribute to the stream as a Java short.
   *
   * @param x the value to pass to the database.
   */
  void writeShort(short x) throws SQLException;

  /**
   * Write the next attribute to the stream as a Java int.
   *
   * @param x the value to pass to the database.
   */
  void writeInt(int x) throws SQLException;

  /**
   * Write the next attribute to the stream as a Java long.
   *
   * @param x the value to pass to the database.
   */
  void writeLong(long x) throws SQLException;

  /**
   * Write the next attribute to the stream as a Java float.
   *
   * @param x the value to pass to the database.
   */
  void writeFloat(float x) throws SQLException;

  /**
   * Write the next attribute to the stream as a Java double.
   *
   * @param x the value to pass to the database.
   */
  void writeDouble(double x) throws SQLException;

  /**
   * Write the next attribute to the stream as a java.math.BigDecimal object.
   *
   * @param x the value to pass to the database.
   */
  void writeBigDecimal(java.math.BigDecimal x) throws SQLException;

  /**
   * Write the next attribute to the stream as an array of bytes.
   *
   * @param x the value to pass to the database.
   */
  void writeBytes(byte[] x) throws SQLException;

  /**
   * Write the next attribute to the stream as a java.sql.Date object.
   *
   * @param x the value to pass to the database.
   */
  void writeDate(java.sql.Date x) throws SQLException;

  /**
   * Write the next attribute to the stream as a java.sql.Time object.
   *
   * @param x the value to pass to the database.
   */
  void writeTime(java.sql.Time x) throws SQLException;

  /**
   * Write the next attribute to the stream as a java.sql.Timestamp object.
   *
   * @param x the value to pass to the database.
   */
  void writeTimestamp(java.sql.Timestamp x) throws SQLException;

  /**
   * Return the next attribute to the stream as a stream of Unicode characters.
   *
   * @param x the value to pass to the database.
   */
  void writeCharacterStream(java.io.Reader x) throws SQLException;

  /**
   * Return the next attribute to the stream as a stream of ASCII characters.
   *
   * @param x the value to pass to the database.
   */
  void writeAsciiStream(java.io.InputStream x) throws SQLException;

  /**
   * Return the next attribute to the stream as a stream of uninterpreted
   * bytes.
   *
   * @param x the value to pass to the database.
   */
  void writeBinaryStream(java.io.InputStream x) throws SQLException;
  
  //================================================================
  // Methods for writing items of SQL user-defined types to the stream.
  // These methods pass objects to the database as values of SQL
  // Structured Types, Distinct Types, Constructed Types, and Locator
  // Types.  They decompose the Java object(s) and write leaf data
  // items using the methods above.
  //================================================================

  /**
   * Write to the stream the data contained in the given object.
   * When @x is null, the method writes an SQL NULL to the stream.  
   * Otherwise, it calls the SQLData.writeSQL method of the @x, which 
   * writes to the stream using the protocol described for 
   * SQLData.writeSQL.
   * 
   * @param x the object representing data of an SQL structured or
   * distinct type
   */
  void writeObject(SQLData x) throws SQLException;

  /**
   * Write a REF(&lt;structured-type&gt;) to the stream.
   *
   * @param x an object representing data of an SQL REF Type
   */
  void writeRef(Ref x) throws SQLException;

  /**
   * Write a BLOB to the stream.
   *
   * @param x an object representing a BLOB
   */
  void writeBlob(Blob x) throws SQLException;

  /**
   * Write a CLOB to the stream.
   *
   * @param x an object representing a CLOB
   */
  void writeClob(Clob x) throws SQLException;

  /**
   * Write a structured-type to the stream.
   *
   * @param x an object representing data of a Structured Type
   */
  void writeStruct(Struct x) throws SQLException;

  /**
   * Write an array to the stream.
   *
   * @param x an object representing an SQL array
   */
  void writeArray(Array x) throws SQLException;

}
 
