001 /*
002 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package java.sql;
027
028 /**
029 *
030 * The representation (mapping) in the Java programming language of an SQL ROWID
031 * value. An SQL ROWID is a built-in type, a value of which can be thought of as
032 * an address for its identified row in a database table. Whether that address
033 * is logical or, in any respects, physical is determined by its originating data
034 * source.
035 * <p>
036 * Methods in the interfaces <code>ResultSet</code>, <code>CallableStatement</code>,
037 * and <code>PreparedStatement</code>, such as <code>getRowId</code> and <code>setRowId</code>
038 * allow a programmer to access a SQL <code>ROWID</code> value. The <code>RowId</code>
039 * interface provides a method
040 * for representing the value of the <code>ROWID</code> as a byte array or as a
041 * <code>String</code>.
042 * <p>
043 * The method <code>getRowIdLifetime</code> in the interface <code>DatabaseMetaData</code>,
044 * can be used
045 * to determine if a <code>RowId</code> object remains valid for the duration of the transaction in
046 * which the <code>RowId</code> was created, the duration of the session in which
047 * the <code>RowId</code> was created,
048 * or, effectively, for as long as its identified row is not deleted. In addition
049 * to specifying the duration of its valid lifetime outside its originating data
050 * source, <code>getRowIdLifetime</code> specifies the duration of a <code>ROWID</code>
051 * value's valid lifetime
052 * within its originating data source. In this, it differs from a large object,
053 * because there is no limit on the valid lifetime of a large object within its
054 * originating data source.
055 * <p>
056 * All methods on the <code>RowId</code> interface must be fully implemented if the
057 * JDBC driver supports the data type.
058 *
059 * @see java.sql.DatabaseMetaData
060 * @since 1.6
061 */
062
063 public interface RowId {
064 /**
065 * Compares this <code>RowId</code> to the specified object. The result is
066 * <code>true</code> if and only if the argument is not null and is a RowId
067 * object that represents the same ROWID as this object.
068 * <p>
069 * It is important
070 * to consider both the origin and the valid lifetime of a <code>RowId</code>
071 * when comparing it to another <code>RowId</code>. If both are valid, and
072 * both are from the same table on the same data source, then if they are equal
073 * they identify
074 * the same row; if one or more is no longer guaranteed to be valid, or if
075 * they originate from different data sources, or different tables on the
076 * same data source, they may be equal but still
077 * not identify the same row.
078 *
079 * @param obj the <code>Object</code> to compare this <code>RowId</code> object
080 * against.
081 * @return true if the <code>RowId</code>s are equal; false otherwise
082 * @since 1.6
083 */
084 boolean equals(Object obj);
085
086 /**
087 * Returns an array of bytes representing the value of the SQL <code>ROWID</code>
088 * designated by this <code>java.sql.RowId</code> object.
089 *
090 * @return an array of bytes, whose length is determined by the driver supplying
091 * the connection, representing the value of the ROWID designated by this
092 * java.sql.RowId object.
093 */
094 byte[] getBytes();
095
096 /**
097 * Returns a String representing the value of the SQL ROWID designated by this
098 * <code>java.sql.RowId</code> object.
099 * <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 }
|