/*
 * @(#)SQLData.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
 *
 * The SQLData interface is implemented by a Java class that is
 * registered in a type mapping.
 */

public interface SQLData {

  /** 
  * Called by the JDBC driver to determine the fully qualified 
  * name of the SQL user-defined type that this object represents.
  *
  * @returns the type name that was passed to method readSql()
  *          when this object was constructed and populated.
  */
  String getSQLTypeName() throws SQLException;

  /**
  * Populate this object with data read from the database.
  * The implementation of the method must follow this protocol:
  * 
  * Read each of the attributes or elements of the SQL
  * type, by calling a method of the input stream to read each
  * item, in the order that they appear in the SQL definition
  * of the type.  Assign those data to appropriate fields or 
  * elements (of this or other objects).
  * Specifically, make these method calls:
  * for a Distinct Type: read a single data element.
  * for a Structured Type: read each attribute of the SQL type.
  *
  * The JDBC driver initializes the input stream with a type map
  * before calling this method which is used by the appropriate
  * readXXX() methods on the stream.
  *
  * @param stream the input SQL data stream
  * @param descriptor the SQL type of the value on the data stream
  */
  void readSQL (SQLInput stream, String typeName) throws SQLException;

  /**
  * Write this object to the given SQL data stream.
  * The implementation of the method must follow this protocol:
  *
  * Write each of the attributes of the SQL type, by calling a 
  * method of the output stream to write each item, in the order that 
  * they appear in the SQL definition of the type.
  * Specifically, make these method calls:
  * for a Distinct Type: write its single data element.
  * for a Structured Type: write a value for each attribute of the SQL type.
  *
  * @param stream the output SQL data stream
  */
  void writeSQL (SQLOutput stream) throws SQLException;
}

