jdk/src/share/classes/java/sql/RowId.java
changeset 2 90ce3da70b43
child 5506 202f599c92aa
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 /*
       
     2  * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 
       
    26 package java.sql;
       
    27 
       
    28 /**
       
    29  *
       
    30  * The representation (mapping) in the Java programming language of an SQL ROWID
       
    31  * value. An SQL ROWID is a built-in type, a value of which can be thought of as
       
    32  * an address  for its identified row in a database table. Whether that address
       
    33  * is logical or, in any  respects, physical is determined by its originating data
       
    34  * source.
       
    35  * <p>
       
    36  * Methods in the interfaces <code>ResultSet</code>, <code>CallableStatement</code>,
       
    37  * and <code>PreparedStatement</code>, such as <code>getRowId</code> and <code>setRowId</code>
       
    38  * allow a programmer to access a SQL <code>ROWID</code>  value. The <code>RowId</code>
       
    39  * interface provides a method
       
    40  * for representing the value of the <code>ROWID</code> as a byte array or as a
       
    41  * <code>String</code>.
       
    42  * <p>
       
    43  * The method <code>getRowIdLifetime</code> in the interface <code>DatabaseMetaData</code>,
       
    44  * can be used
       
    45  * to determine if a <code>RowId</code> object remains valid for the duration of the transaction in
       
    46  * which  the <code>RowId</code> was created, the duration of the session in which
       
    47  * the <code>RowId</code> was created,
       
    48  * or, effectively, for as long as its identified row is not deleted. In addition
       
    49  * to specifying the duration of its valid lifetime outside its originating data
       
    50  * source, <code>getRowIdLifetime</code> specifies the duration of a <code>ROWID</code>
       
    51  * value's valid lifetime
       
    52  * within its originating data source. In this, it differs from a large object,
       
    53  * because there is no limit on the valid lifetime of a large  object within its
       
    54  * originating data source.
       
    55  * <p>
       
    56  * All methods on the <code>RowId</code> interface must be fully implemented if the
       
    57  * JDBC driver supports the data type.
       
    58  *
       
    59  * @see java.sql.DatabaseMetaData
       
    60  * @since 1.6
       
    61  */
       
    62 
       
    63 public interface RowId {
       
    64     /**
       
    65      * Compares this <code>RowId</code> to the specified object. The result is
       
    66      * <code>true</code> if and only if the argument is not null and is a RowId
       
    67      * object that represents the same ROWID as  this object.
       
    68      * <p>
       
    69      * It is important
       
    70      * to consider both the origin and the valid lifetime of a <code>RowId</code>
       
    71      * when comparing it to another <code>RowId</code>. If both are valid, and
       
    72      * both are from the same table on the same data source, then if they are equal
       
    73      * they identify
       
    74      * the same row; if one or more is no longer guaranteed to be valid, or if
       
    75      * they originate from different data sources, or different tables on the
       
    76      * same data source, they  may be equal but still
       
    77      * not identify the same row.
       
    78      *
       
    79      * @param obj the <code>Object</code> to compare this <code>RowId</code> object
       
    80      *     against.
       
    81      * @return true if the <code>RowId</code>s are equal; false otherwise
       
    82      * @since 1.6
       
    83      */
       
    84     boolean equals(Object obj);
       
    85 
       
    86     /**
       
    87      * Returns an array of bytes representing the value of the SQL <code>ROWID</code>
       
    88      * designated by this <code>java.sql.RowId</code> object.
       
    89      *
       
    90      * @return an array of bytes, whose length is determined by the driver supplying
       
    91      *     the connection, representing the value of the ROWID designated by this
       
    92      *     java.sql.RowId object.
       
    93      */
       
    94      byte[] getBytes();
       
    95 
       
    96      /**
       
    97       * Returns a String representing the value of the SQL ROWID designated by this
       
    98       * <code>java.sql.RowId</code> object.
       
    99       * <p>
       
   100       *Like <code>java.sql.Date.toString()</code>
       
   101       * returns the contents of its DATE as the <code>String</code> "2004-03-17"
       
   102       * rather than as  DATE literal in SQL (which would have been the <code>String</code>
       
   103       * DATE "2004-03-17"), toString()
       
   104       * returns the contents of its ROWID in a form specific to the driver supplying
       
   105       * the connection, and possibly not as a <code>ROWID</code> literal.
       
   106       *
       
   107       * @return a String whose format is determined by the driver supplying the
       
   108       *     connection, representing the value of the <code>ROWID</code> designated
       
   109       *     by this <code>java.sql.RowId</code>  object.
       
   110       */
       
   111      String toString();
       
   112 
       
   113      /**
       
   114       * Returns a hash code value of this <code>RowId</code> object.
       
   115       *
       
   116       * @return a hash code for the <code>RowId</code>
       
   117       */
       
   118      int hashCode();
       
   119 
       
   120 }