jdk/src/share/classes/java/sql/Ref.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.sql;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * The mapping in the Java programming language of an SQL <code>REF</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * value, which is a reference to an SQL structured type value in the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * SQL <code>REF</code> values are stored in a table that contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * instances of a referenceable SQL structured type, and each <code>REF</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * value is a unique identifier for one instance in that table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * An SQL <code>REF</code> value may be used in place of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * SQL structured type it references, either as a column value in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * table or an attribute value in a structured type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Because an SQL <code>REF</code> value is a logical pointer to an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * SQL structured type, a <code>Ref</code> object is by default also a logical
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * pointer. Thus, retrieving an SQL <code>REF</code> value as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * a <code>Ref</code> object does not materialize
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * the attributes of the structured type on the client.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * A <code>Ref</code> object can be stored in the database using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <code>PreparedStatement.setRef</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * All methods on the <code>Ref</code> interface must be fully implemented if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * JDBC driver supports the data type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @see Struct
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
public interface Ref {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * Retrieves the fully-qualified SQL name of the SQL structured type that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * this <code>Ref</code> object references.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @return the fully-qualified SQL name of the referenced SQL structured type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    String getBaseTypeName() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Retrieves the referenced object and maps it to a Java type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * using the given type map.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @param map a <code>java.util.Map</code> object that contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *        the mapping to use (the fully-qualified name of the SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *        structured type being referenced and the class object for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     *        <code>SQLData</code> implementation to which the SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *        structured type will be mapped)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @return  a Java <code>Object</code> that is the custom mapping for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *          the SQL structured type to which this <code>Ref</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *          object refers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @see #setObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    Object getObject(java.util.Map<String,Class<?>> map) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Retrieves the SQL structured type instance referenced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * this <code>Ref</code> object.  If the connection's type map has an entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * for the structured type, the instance will be custom mapped to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * the Java class indicated in the type map.  Otherwise, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * structured type instance will be mapped to a <code>Struct</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @return  a Java <code>Object</code> that is the mapping for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     *          the SQL structured type to which this <code>Ref</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     *          object refers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @see #setObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    Object getObject() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * Sets the structured type value that this <code>Ref</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * object references to the given instance of <code>Object</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * The driver converts this to an SQL structured type when it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * sends it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param value an <code>Object</code> representing the SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *        structured type instance that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *        <code>Ref</code> object will reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @see #getObject()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @see #getObject(Map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @see PreparedStatement#setObject(int, Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @see CallableStatement#setObject(String, Object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    void setObject(Object value) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
}