package org.okip.service.dbc.api;



/*
   Copyright (c) 2002 Massachusetts Institute of Technology

   This work, including any software, documents, or other related items
   (the "Work"), is being provided by the copyright holder(s) subject to
   the terms of the MIT OKI(TM) API Definition License. By obtaining,
   using and/or copying this Work, you agree that you have read,
   understand, and will comply with the following terms and conditions of
   the MIT OKI(TM) API Definition License:

   You may use, copy, and distribute unmodified versions of this Work for
   any purpose, without fee or royalty, provided that you include the
   following on ALL copies of the Work that you make or distribute:

    *  The full text of the MIT OKI(TM) API Definition License in a
       location viewable to users of the redistributed Work.

    *  Any pre-existing intellectual property disclaimers, notices, or
       terms and conditions. If none exist, a short notice similar to the
       following should be used within the body of any redistributed
       Work: "Copyright (c) 2002 Massachusetts Institute of Technology. All
       Rights Reserved."

   You may modify or create Derivatives of this Work only for your
   internal purposes. You shall not distribute or transfer any such
   Derivative of this Work to any location or any other third party. For
   purposes of this license, "Derivative" shall mean any derivative of
   the Work as defined in the United States Copyright Act of 1976, such
   as a translation or modification.

   THIS WORK PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE WORK
   OR THE USE OR OTHER DEALINGS IN THE WORK.

   The name and trademarks of copyright holder(s) and/or MIT may NOT be
   used in advertising or publicity pertaining to the Work without
   specific, written prior permission. Title to copyright in the Work and
   any associated documentation will at all times remain with the
   copyright holders.

*/

/**
 *A table of data representing a database result set, which is usually
 *generated by executing a statement that queries the database.
 * <p>
 * @see(java.sql.ResultSet)
 * <p>
 * Licensed under the {@link org.okip.service.ApiLicense MIT OKI&#153; API Definition License}.
 *
 * @version $Name:  $ / $Revision: 1.2 $ / $Date: 2002/07/29 18:42:43 $ */

/**
 * An object that can be used to get information about the types
 * and properties of the columns in a <code>ResultSet</code> object.
 * The following code fragment creates the <code>ResultSet</code> object rs,
 * creates the <code>ResultSetMetaData</code> object rsmd, and uses rsmd
 * to find out how many columns rs has and whether the first column in rs
 * can be used in a <code>WHERE</code> clause.
 * <PRE>
 *
 *     ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");
 *     ResultSetMetaData rsmd = rs.getMetaData();
 *     int numberOfColumns = rsmd.getColumnCount();
 *     boolean b = rsmd.isSearchable(1);
 *
 * </PRE>
 * <p>
 * @see(java.sql.ResultSetMetaData)
 * <p>
 * Licensed under the {@link org.okip.service.ApiLicense MIT OKI&#153; API Definition License}.
 *
 * @version $Name:  $ / $Revision: 1.2 $ / $Date: 2002/07/29 18:42:43 $ */

public interface ResultSetMetaData
extends java.io.Serializable {

  /**
   * Returns the number of columns in this <code>ResultSet</code> object.
   *
   * @return the number of columns
   *
   * @throws DbcException
   */
  int getColumnCount()
  throws DbcException;

  /**
   * Indicates whether the designated column is automatically numbered, thus read-only.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return <code>true</code> if so; <code>false</code> otherwise
   *
   * @throws DbcException
   */
  boolean isAutoIncrement(int column)
  throws DbcException;

  /**
   * Indicates whether a column's case matters.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return <code>true</code> if so; <code>false</code> otherwise
   *
   * @throws DbcException
   */
  boolean isCaseSensitive(int column)
  throws DbcException;

  /**
   * Indicates whether the designated column can be used in a where clause.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return <code>true</code> if so; <code>false</code> otherwise
   *
   * @throws DbcException
   */
  boolean isSearchable(int column)
  throws DbcException;

  /**
   * Indicates whether the designated column is a cash value.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return <code>true</code> if so; <code>false</code> otherwise
   *
   * @throws DbcException
   */
  boolean isCurrency(int column)
  throws DbcException;

  /**
   * Indicates the nullability of values in the designated column.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return the nullability status of the given column; one of <code>columnNoNulls</code>,
   *          <code>columnNullable</code> or <code>columnNullableUnknown</code>
   *
   * @throws DbcException
   */
  int isNullable(int column)
  throws DbcException;

  /**
   * The constant indicating that a
   * column does not allow <code>NULL</code> values.
   */
  int columnNoNulls = 0;

  /**
   * The constant indicating that a
   * column allows <code>NULL</code> values.
   */
  int columnNullable = 1;

  /**
   * The constant indicating that the
   * nullability of a column's values is unknown.
   */
  int columnNullableUnknown = 2;

  /**
   * Indicates whether values in the designated column are signed numbers.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return <code>true</code> if so; <code>false</code> otherwise
   *
   * @throws DbcException
   */
  boolean isSigned(int column)
  throws DbcException;

  /**
   * Indicates the designated column's normal maximum width in characters.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return the normal maximum number of characters allowed as the width
   *          of the designated column
   *
   * @throws DbcException
   */
  int getColumnDisplaySize(int column)
  throws DbcException;

  /**
   * Gets the designated column's suggested title for use in printouts and
   * displays.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return the suggested column title
   *
   * @throws DbcException
   */
  String getColumnLabel(int column)
  throws DbcException;

  /**
   * Get the designated column's name.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return column name
   *
   * @throws DbcException
   */
  String getColumnName(int column)
  throws DbcException;

  /**
   * Get the designated column's table's schema.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return schema name or "" if not applicable
   *
   * @throws DbcException
   */
  String getSchemaName(int column)
  throws DbcException;

  /**
   * Get the designated column's number of decimal digits.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return precision
   *
   * @throws DbcException
   */
  int getPrecision(int column)
  throws DbcException;

  /**
   * Gets the designated column's number of digits to right of the decimal point.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return scale
   *
   * @throws DbcException
   */
  int getScale(int column)
  throws DbcException;

  /**
   * Gets the designated column's table name.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return table name or "" if not applicable
   *
   * @throws DbcException
   */
  String getTableName(int column)
  throws DbcException;

  /**
   * Gets the designated column's table's catalog name.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return the name of the catalog for the table in which the given column
   *          appears or "" if not applicable
   *
   * @throws DbcException
   */
  String getCatalogName(int column)
  throws DbcException;

  /**
   * Retrieves the designated column's SQL type.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return SQL type from java.sql.Types
   * @see Types
   */
  int getColumnType(int column)
  throws DbcException;

  /**
   * Retrieves the designated column's database-specific type name.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return type name used by the database. If the column type is
   * a user-defined type, then a fully-qualified type name is returned.
   *
   * @throws DbcException
   */
  String getColumnTypeName(int column)
  throws DbcException;

  /**
   * Indicates whether the designated column is definitely not writable.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return <code>true</code> if so; <code>false</code> otherwise
   *
   * @throws DbcException
   */
  boolean isReadOnly(int column)
  throws DbcException;

  /**
   * Indicates whether it is possible for a write on the designated column to succeed.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return <code>true</code> if so; <code>false</code> otherwise
   *
   * @throws DbcException
   */
  boolean isWritable(int column)
  throws DbcException;

  /**
   * Indicates whether a write on the designated column will definitely succeed.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return <code>true</code> if so; <code>false</code> otherwise
   *
   * @throws DbcException
   */
  boolean isDefinitelyWritable(int column)
  throws DbcException;

  //--------------------------JDBC 2.0-----------------------------------

  /**
   * <p>Returns the fully-qualified name of the Java class whose instances
   * are manufactured if the method <code>ResultSet.getObject</code>
   * is called to retrieve a value
   * from the column.  <code>ResultSet.getObject</code> may return a subclass of the
   * class returned by this method.
   *
   * @param column the first column is 1, the second is 2, ...
   * @return the fully-qualified name of the class in the Java programming
   *         language that would be used by the method
   * <code>ResultSet.getObject</code> to retrieve the value in the specified
   * column. This is the class name used for custom mapping.
   * @since 1.2
   */
  String getColumnClassName(int column)
  throws DbcException;
}
