jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java
author lancea
Thu, 26 Jan 2012 19:41:35 -0500
changeset 11683 5e02efd89af6
parent 11129 f9ad1aadf3fa
child 14409 d879c92507ec
permissions -rw-r--r--
7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl Reviewed-by: forax
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
11683
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 11129
diff changeset
     2
 * Copyright (c) 2003, 2012, 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.math.*;
11683
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 11129
diff changeset
    32
import java.util.Arrays;
2
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
import javax.sql.rowset.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * A serialized mapping in the Java programming language of an SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * structured type. Each attribute that is not already serialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * is mapped to a serialized form, and if an attribute is itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * a structured type, each of its attributes that is not already
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * serialized is mapped to a serialized form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * In addition, the structured type is custom mapped to a class in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Java programming language if there is such a mapping, as are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * its attributes, if appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * The <code>SerialStruct</code> class provides a constructor for creating
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * an instance from a <code>Struct</code> object, a method for retrieving
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * the SQL type name of the SQL structured type in the database, and methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * for retrieving its attribute values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
public class SerialStruct implements Struct, Serializable, Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * The SQL type name for the structured type that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * <code>SerialStruct</code> object represents.  This is the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * used in the SQL definition of the SQL structured type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private String SQLTypeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * An array of <code>Object</code> instances in  which each
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * element is an attribute of the SQL structured type that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * <code>SerialStruct</code> object represents.  The attributes are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * ordered according to their order in the definition of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * SQL structured type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private Object attribs[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Constructs a <code>SerialStruct</code> object from the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * <code>Struct</code> object, using the given <code>java.util.Map</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * object for custom mapping the SQL structured type or any of its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * attributes that are SQL structured types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @param map a <code>java.util.Map</code> object in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *        each entry consists of 1) a <code>String</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     *        giving the fully qualified name of a UDT and 2) the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *        <code>Class</code> object for the <code>SQLData</code> implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *        that defines how the UDT is to be mapped
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @throws SerialException if an error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @see java.sql.Struct
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     public SerialStruct(Struct in, Map<String,Class<?>> map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
         throws SerialException
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        // get the type name
6692
aef4e294026f 6988993: Address Findbugs warnings for the use of String Constructor
lancea
parents: 5506
diff changeset
    98
        SQLTypeName = in.getSQLTypeName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        System.out.println("SQLTypeName: " + SQLTypeName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        // get the attributes of the struct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        attribs = in.getAttributes(map);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
         * the array may contain further Structs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
         * and/or classes that have been mapped,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
         * other types that we have to serialize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        mapToSerial(map);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        } catch (SQLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            throw new SerialException(e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
      * Constructs a <code>SerialStruct</code> object from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
      * given <code>SQLData</code> object, using the given type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
      * map to custom map it to a class in the Java programming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      * language.  The type map gives the SQL type and the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
      * to which it is mapped.  The <code>SQLData</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
      * defines the class to which the SQL type will be mapped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
      * @param in an instance of the <code>SQLData</code> class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
      *           that defines the mapping of the SQL structured
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
      *           type to one or more objects in the Java programming language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
      * @param map a <code>java.util.Map</code> object in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
      *        each entry consists of 1) a <code>String</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
      *        giving the fully qualified name of a UDT and 2) the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
      *        <code>Class</code> object for the <code>SQLData</code> implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
      *        that defines how the UDT is to be mapped
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
      * @throws SerialException if an error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
      */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public SerialStruct(SQLData in, Map<String,Class<?>> map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        throws SerialException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        //set the type name
6692
aef4e294026f 6988993: Address Findbugs warnings for the use of String Constructor
lancea
parents: 5506
diff changeset
   141
        SQLTypeName = in.getSQLTypeName();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 6692
diff changeset
   143
        Vector<Object> tmp = new Vector<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        in.writeSQL(new SQLOutputImpl(tmp, map));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        attribs = tmp.toArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        } catch (SQLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            throw new SerialException(e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Retrieves the SQL type name for this <code>SerialStruct</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * object. This is the name used in the SQL definition of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * structured type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @return a <code>String</code> object representing the SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *         type name for the SQL structured type that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *         <code>SerialStruct</code> object represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @throws SerialException if an error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public String getSQLTypeName() throws SerialException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        return SQLTypeName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Retrieves an array of <code>Object</code> values containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * attributes of the SQL structured type that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * <code>SerialStruct</code> object represents.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @return an array of <code>Object</code> values, with each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *         element being an attribute of the SQL structured type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *         that this <code>SerialStruct</code> object represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @throws SerialException if an error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public Object[]  getAttributes() throws SerialException {
11683
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 11129
diff changeset
   178
        Object[] val = this.attribs;
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 11129
diff changeset
   179
        return (val == null) ? null : Arrays.copyOf(val, val.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Retrieves the attributes for the SQL structured type that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * this <code>SerialStruct</code> represents as an array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * <code>Object</code> values, using the given type map for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * custom mapping if appropriate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param map a <code>java.util.Map</code> object in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *        each entry consists of 1) a <code>String</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *        giving the fully qualified name of a UDT and 2) the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *        <code>Class</code> object for the <code>SQLData</code> implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *        that defines how the UDT is to be mapped
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @return an array of <code>Object</code> values, with each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *         element being an attribute of the SQL structured
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *         type that this <code>SerialStruct</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *         represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @throws SerialException if an error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public Object[] getAttributes(Map<String,Class<?>> map)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        throws SerialException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    {
11683
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 11129
diff changeset
   202
        Object[] val = this.attribs;
5e02efd89af6 7133815: address the findbug errors in CachedRowSetImpl, SerialStruct, BaseRow, SerialInputImpl, SerialOutputImpl
lancea
parents: 11129
diff changeset
   203
        return (val == null) ? null : Arrays.copyOf(val, val.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * Maps attributes of an SQL structured type that are not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * serialized to a serialized form, using the given type map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * for custom mapping when appropriate.  The following types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * in the Java programming language are mapped to their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * serialized forms:  <code>Struct</code>, <code>SQLData</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <code>Ref</code>, <code>Blob</code>, <code>Clob</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * <code>Array</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * This method is called internally and is not used by an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * application programmer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @param map a <code>java.util.Map</code> object in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *        each entry consists of 1) a <code>String</code> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *        giving the fully qualified name of a UDT and 2) the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *        <code>Class</code> object for the <code>SQLData</code> implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *        that defines how the UDT is to be mapped
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @throws SerialException if an error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     */
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 6692
diff changeset
   226
    private void mapToSerial(Map<String,Class<?>> map) throws SerialException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        for (int i = 0; i < attribs.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            if (attribs[i] instanceof Struct) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                attribs[i] = new SerialStruct((Struct)attribs[i], map);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            } else if (attribs[i] instanceof SQLData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                attribs[i] = new SerialStruct((SQLData)attribs[i], map);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            } else if (attribs[i] instanceof Blob) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                attribs[i] = new SerialBlob((Blob)attribs[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            } else if (attribs[i] instanceof Clob) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                attribs[i] = new SerialClob((Clob)attribs[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            } else if (attribs[i] instanceof Ref) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                attribs[i] = new SerialRef((Ref)attribs[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            } else if (attribs[i] instanceof java.sql.Array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                attribs[i] = new SerialArray((java.sql.Array)attribs[i], map);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        } catch (SQLException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            throw new SerialException(e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    /**
6692
aef4e294026f 6988993: Address Findbugs warnings for the use of String Constructor
lancea
parents: 5506
diff changeset
   253
     * The identifier that assists in the serialization of this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * <code>SerialStruct</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    static final long serialVersionUID = -8322445504027483372L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
}