jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java
author lancea
Mon, 04 Oct 2010 13:04:09 -0400
changeset 6697 39929804f9d4
parent 5506 202f599c92aa
child 11129 f9ad1aadf3fa
permissions -rw-r--r--
6989139: Address JDBC Findbugs where Number type Constructor are used Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
6697
39929804f9d4 6989139: Address JDBC Findbugs where Number type Constructor are used
lancea
parents: 5506
diff changeset
     2
 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
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 javax.sql.rowset.serial;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.sql.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.sql.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.String;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.math.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * The output stream for writing the attributes of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * custom-mapped user-defined type (UDT) back to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * The driver uses this interface internally, and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * methods are never directly invoked by an application programmer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * When an application calls the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * method <code>PreparedStatement.setObject</code>, the driver
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * checks to see whether the value to be written is a UDT with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * a custom mapping.  If it is, there will be an entry in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * type map containing the <code>Class</code> object for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * class that implements <code>SQLData</code> for this UDT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * If the value to be written is an instance of <code>SQLData</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * the driver will create an instance of <code>SQLOutputImpl</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * and pass it to the method <code>SQLData.writeSQL</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * The method <code>writeSQL</code> in turn calls the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * appropriate <code>SQLOutputImpl.writeXXX</code> methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * to write data from the <code>SQLData</code> object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * the <code>SQLOutputImpl</code> output stream as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * representation of an SQL user-defined type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
public class SQLOutputImpl implements SQLOutput {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * A reference to an existing vector that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * contains the attributes of a <code>Struct</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private Vector attribs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * The type map the driver supplies to a newly created
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * <code>SQLOutputImpl</code> object.  This type map
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * indicates the <code>SQLData</code> class whose
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * <code>writeSQL</code> method will be called.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * method will in turn call the appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * <code>SQLOutputImpl</code> writer methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private Map map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Creates a new <code>SQLOutputImpl</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * initialized with the given vector of attributes and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * type map.  The driver will use the type map to determine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * which <code>SQLData.writeSQL</code> method to invoke.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * This method will then call the appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * <code>SQLOutputImpl</code> writer methods in order and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * thereby write the attributes to the new output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @param attributes a <code>Vector</code> object containing the attributes of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *        the UDT to be mapped to one or more objects in the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *        programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @param map a <code>java.util.Map</code> object containing zero or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *        more entries, with each entry consisting of 1) a <code>String</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *        giving the fully qualified name of a UDT and 2) the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *        <code>Class</code> object for the <code>SQLData</code> implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *        that defines how the UDT is to be mapped
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @throws SQLException if the <code>attributes</code> or the <code>map</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *        is a <code>null</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public SQLOutputImpl(Vector<?> attributes, Map<String,?> map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        throws SQLException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        if ((attributes == null) || (map == null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            throw new SQLException("Cannot instantiate a SQLOutputImpl " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            "instance with null parameters");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        this.attribs = attributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        this.map = map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    //================================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    // Methods for writing attributes to the stream of SQL data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    // These methods correspond to the column-accessor methods of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    // java.sql.ResultSet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    //================================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Writes a <code>String</code> in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * it to an SQL <code>CHAR</code>, <code>VARCHAR</code>, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * <code>LONGVARCHAR</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public void writeString(String x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        //System.out.println("Adding :"+x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * Writes a <code>boolean</code> in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * it to an SQL <code>BIT</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public void writeBoolean(boolean x) throws SQLException {
6697
39929804f9d4 6989139: Address JDBC Findbugs where Number type Constructor are used
lancea
parents: 5506
diff changeset
   140
        attribs.add(Boolean.valueOf(x));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * Writes a <code>byte</code> in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * it to an SQL <code>BIT</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public void writeByte(byte x) throws SQLException {
6697
39929804f9d4 6989139: Address JDBC Findbugs where Number type Constructor are used
lancea
parents: 5506
diff changeset
   154
        attribs.add(Byte.valueOf(x));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * Writes a <code>short</code> in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * it to an SQL <code>SMALLINT</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public void writeShort(short x) throws SQLException {
6697
39929804f9d4 6989139: Address JDBC Findbugs where Number type Constructor are used
lancea
parents: 5506
diff changeset
   168
        attribs.add(Short.valueOf(x));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * Writes an <code>int</code> in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * it to an SQL <code>INTEGER</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public void writeInt(int x) throws SQLException {
6697
39929804f9d4 6989139: Address JDBC Findbugs where Number type Constructor are used
lancea
parents: 5506
diff changeset
   182
        attribs.add(Integer.valueOf(x));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * Writes a <code>long</code> in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * it to an SQL <code>BIGINT</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public void writeLong(long x) throws SQLException {
6697
39929804f9d4 6989139: Address JDBC Findbugs where Number type Constructor are used
lancea
parents: 5506
diff changeset
   196
        attribs.add(Long.valueOf(x));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * Writes a <code>float</code> in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * it to an SQL <code>REAL</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public void writeFloat(float x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        attribs.add(new Float(x));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Writes a <code>double</code> in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * it to an SQL <code>DOUBLE</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    public void writeDouble(double x) throws SQLException{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        attribs.add(new Double(x));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * Writes a <code>java.math.BigDecimal</code> object in the Java programming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * language to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * it to an SQL <code>NUMERIC</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    public void writeBigDecimal(java.math.BigDecimal x) throws SQLException{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * Writes an array of <code>bytes</code> in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * it to an SQL <code>VARBINARY</code> or <code>LONGVARBINARY</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public void writeBytes(byte[] x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * Writes a <code>java.sql.Date</code> object in the Java programming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * language to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * it to an SQL <code>DATE</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public void writeDate(java.sql.Date x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * Writes a <code>java.sql.Time</code> object in the Java programming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * language to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * it to an SQL <code>TIME</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    public void writeTime(java.sql.Time x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * Writes a <code>java.sql.Timestamp</code> object in the Java programming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * language to this <code>SQLOutputImpl</code> object. The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * it to an SQL <code>TIMESTAMP</code> before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    public void writeTimestamp(java.sql.Timestamp x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * Writes a stream of Unicode characters to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * <code>SQLOutputImpl</code> object. The driver will do any necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * conversion from Unicode to the database <code>CHAR</code> format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    public void writeCharacterStream(java.io.Reader x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
         BufferedReader bufReader = new BufferedReader(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
         try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
             int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
             while( (i = bufReader.read()) != -1 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                char ch = (char)i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                StringBuffer strBuf = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                strBuf.append(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                String str = new String(strBuf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                String strLine = bufReader.readLine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                writeString(str.concat(strLine));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
         } catch(IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * Writes a stream of ASCII characters to this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * <code>SQLOutputImpl</code> object. The driver will do any necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * conversion from ASCII to the database <code>CHAR</code> format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    public void writeAsciiStream(java.io.InputStream x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
         BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
         try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
               int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
               while( (i=bufReader.read()) != -1 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                char ch = (char)i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                StringBuffer strBuf = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                strBuf.append(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                String str = new String(strBuf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                String strLine = bufReader.readLine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                writeString(str.concat(strLine));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
          }catch(IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            throw new SQLException(ioe.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * Writes a stream of uninterpreted bytes to this <code>SQLOutputImpl</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    public void writeBinaryStream(java.io.InputStream x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
         BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
         try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
               int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
             while( (i=bufReader.read()) != -1 ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                char ch = (char)i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                StringBuffer strBuf = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                strBuf.append(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                String str = new String(strBuf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                String strLine = bufReader.readLine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                writeString(str.concat(strLine));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
             }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        } catch(IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            throw new SQLException(ioe.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    //================================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    // Methods for writing items of SQL user-defined types to the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    // These methods pass objects to the database as values of SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    // Structured Types, Distinct Types, Constructed Types, and Locator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    // Types.  They decompose the Java object(s) and write leaf data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    // items using the methods above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    //================================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * Writes to the stream the data contained in the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * <code>SQLData</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * When the <code>SQLData</code> object is <code>null</code>, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * method writes an SQL <code>NULL</code> to the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * Otherwise, it calls the <code>SQLData.writeSQL</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * method of the given object, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * writes the object's attributes to the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * The implementation of the method <code>SQLData.writeSQ</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * calls the appropriate <code>SQLOutputImpl.writeXXX</code> method(s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * for writing each of the object's attributes in order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * The attributes must be read from an <code>SQLInput</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * input stream and written to an <code>SQLOutputImpl</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * output stream in the same order in which they were
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * listed in the SQL definition of the user-defined type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * @param x the object representing data of an SQL structured or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *          distinct type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    public void writeObject(SQLData x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
         * Except for the types that are passed as objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
         * this seems to be the only way for an object to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
         * get a null value for a field in a structure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
         * Note: this means that the class defining SQLData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
         * will need to track if a field is SQL null for itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        if (x == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
         * We have to write out a SerialStruct that contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
         * the name of this class otherwise we don't know
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
         * what to re-instantiate during readSQL()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        attribs.add(new SerialStruct((SQLData)x, map));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * Writes a <code>Ref</code> object in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * to this <code>SQLOutputImpl</code> object.  The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * it to a serializable <code>SerialRef</code> SQL <code>REF</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @param x an object representing an SQL <code>REF</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    public void writeRef(Ref x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        if (x == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        attribs.add(new SerialRef(x));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * Writes a <code>Blob</code> object in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * to this <code>SQLOutputImpl</code> object.  The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * it to a serializable <code>SerialBlob</code> SQL <code>BLOB</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @param x an object representing an SQL <code>BLOB</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    public void writeBlob(Blob x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        if (x == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        attribs.add(new SerialBlob(x));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * Writes a <code>Clob</code> object in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * to this <code>SQLOutputImpl</code> object.  The driver converts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * it to a serializable <code>SerialClob</code> SQL <code>CLOB</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @param x an object representing an SQL <code>CLOB</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    public void writeClob(Clob x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        if (x == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        attribs.add(new SerialClob(x));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * Writes a <code>Struct</code> object in the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * programming language to this <code>SQLOutputImpl</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * object. The driver converts this value to an SQL structured type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * This method should be used when an SQL structured type has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * mapped to a <code>Struct</code> object in the Java programming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * language (the standard mapping).  The method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * <code>writeObject</code> should be used if an SQL structured type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * has been custom mapped to a class in the Java programming language.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * @param x an object representing the attributes of an SQL structured type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    public void writeStruct(Struct x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        SerialStruct s = new SerialStruct(x,map);;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        attribs.add(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * Writes an <code>Array</code> object in the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * programming language to this <code>SQLOutputImpl</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * object. The driver converts this value to a serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * <code>SerialArray</code> SQL <code>ARRAY</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * value before returning it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * @param x an object representing an SQL <code>ARRAY</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    public void writeArray(Array x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        if (x == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            attribs.add(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        attribs.add(new SerialArray(x, map));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * Writes an <code>java.sql.Type.DATALINK</code> object in the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * programming language to this <code>SQLOutputImpl</code> object. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * driver converts this value to a serializable <code>SerialDatalink</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * SQL <code>DATALINK</code> value before return it to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * @param url an object representing a SQL <code>DATALINK</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * @throws SQLException if the <code>SQLOutputImpl</code> object is in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     *        use by a <code>SQLData</code> object attempting to write the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     *        values of a UDT to the database.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    public void writeURL(java.net.URL url) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        if (url == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            attribs.add(url);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        attribs.add(new SerialDatalink(url));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
   * Writes the next attribute to the stream as a <code>String</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
   * in the Java programming language. The driver converts this to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
   * SQL <code>NCHAR</code> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
   * <code>NVARCHAR</code> or <code>LONGNVARCHAR</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
   * (depending on the argument's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
   * size relative to the driver's limits on <code>NVARCHAR</code> values)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
   * when it sends it to the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
   * @param x the value to pass to the database
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
   * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
   * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
   public void writeNString(String x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        throw new UnsupportedOperationException("Operation not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
   * Writes an SQL <code>NCLOB</code> value to the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
   * @param x a <code>NClob</code> object representing data of an SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
   * <code>NCLOB</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
   * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
   * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
   public void writeNClob(NClob x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        throw new UnsupportedOperationException("Operation not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
   * Writes an SQL <code>ROWID</code> value to the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
   * @param x a <code>RowId</code> object representing data of an SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
   * <code>ROWID</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
   * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
   * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
   public void writeRowId(RowId x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        throw new UnsupportedOperationException("Operation not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
   * Writes an SQL <code>XML</code> value to the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
   * @param x a <code>SQLXML</code> object representing data of an SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
   * <code>XML</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
   * @exception SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
   * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
   public void writeSQLXML(SQLXML x) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        throw new UnsupportedOperationException("Operation not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
}