jdk/src/java.sql.rowset/share/classes/com/sun/rowset/WebRowSetImpl.java
author martin
Thu, 30 Oct 2014 07:31:41 -0700
changeset 28059 e576535359cc
parent 25859 3317bb8137f4
permissions -rw-r--r--
8067377: My hobby: caning, then then canning, the the can-can Summary: Fix ALL the stutters! Reviewed-by: rriggs, mchung, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21278
diff changeset
     2
 * Copyright (c) 2003, 2013, 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 com.sun.rowset;
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.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.text.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import org.xml.sax.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import javax.sql.rowset.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import javax.sql.rowset.spi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import com.sun.rowset.providers.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import com.sun.rowset.internal.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * The standard implementation of the <code>WebRowSet</code> interface. See the interface
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 11129
diff changeset
    45
 * definition for full behavior and implementation requirements.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author Jonathan Bruce, Amit Handa
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class WebRowSetImpl extends CachedRowSetImpl implements WebRowSet {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * The <code>WebRowSetXmlReader</code> object that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * <code>WebRowSet</code> object will call when the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * <code>WebRowSet.readXml</code> is invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private WebRowSetXmlReader xmlReader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * The <code>WebRowSetXmlWriter</code> object that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * <code>WebRowSet</code> object will call when the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * <code>WebRowSet.writeXml</code> is invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private WebRowSetXmlWriter xmlWriter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /* This stores the cursor position prior to calling the writeXML.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * This variable is used after the write to restore the position
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * to the point where the writeXml was called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private int curPosBfrWrite;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private SyncProvider provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * Constructs a new <code>WebRowSet</code> object initialized with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * default values for a <code>CachedRowSet</code> object instance. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * provides the <code>RIOptimistic</code> provider to deliver
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * synchronization capabilities to relational datastores and a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * <code>WebRowSetXmlReader</code> object and a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * <code>WebRowSetXmlWriter</code> object to enable XML output
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * capabilities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @throws SQLException if an error occurs in configuring the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * synchronization providers for relational and XML providers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public WebRowSetImpl() throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        // %%%
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        // Needs to use to SPI  XmlReader,XmlWriters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        xmlReader = new WebRowSetXmlReader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        xmlWriter = new WebRowSetXmlWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
    96
     * Constructs a new <code>WebRowSet</code> object initialized with the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * synchronization SPI provider properties as specified in the <code>Hashtable</code>. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * this hashtable is empty or is <code>null</code> the default constructor is invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @throws SQLException if an error occurs in configuring the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * synchronization providers for the relational and XML providers; or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * if the Hashtanle is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 6530
diff changeset
   104
    @SuppressWarnings("rawtypes")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public WebRowSetImpl(Hashtable env) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
6530
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   107
        try {
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   108
           resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   109
        } catch(IOException ioe) {
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   110
            throw new RuntimeException(ioe);
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   111
        }
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   112
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        if ( env == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            throw new SQLException(resBundle.handleGetObject("webrowsetimpl.nullhash").toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        String providerName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            (String)env.get(javax.sql.rowset.spi.SyncFactory.ROWSET_SYNC_PROVIDER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        // set the Reader, this maybe overridden latter
11129
f9ad1aadf3fa 7116445: Miscellaneous warnings in the JDBC/RowSet classes
lancea
parents: 6530
diff changeset
   121
        provider = SyncFactory.getInstance(providerName);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        // xmlReader = provider.getRowSetReader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        // xmlWriter = provider.getRowSetWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    * Populates this <code>WebRowSet</code> object with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    * data in the given <code>ResultSet</code> object and writes itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    * to the given <code>java.io.Writer</code> object in XML format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    * This includes the rowset's data,  properties, and metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    * @throws SQLException if an error occurs writing out the rowset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    *          contents to XML
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public void writeXml(ResultSet rs, java.io.Writer writer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            // WebRowSetImpl wrs = new WebRowSetImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            this.populate(rs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            // Store the cursor position before writing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            curPosBfrWrite = this.getRow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            this.writeXml(writer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Writes this <code>WebRowSet</code> object to the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <code>java.io.Writer</code> object in XML format. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * includes the rowset's data,  properties, and metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @throws SQLException if an error occurs writing out the rowset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *          contents to XML
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public void writeXml(java.io.Writer writer) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        // %%%
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        // This will change to a XmlReader, which over-rides the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        // Xml that is used when a WRS is instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        // WebRowSetXmlWriter xmlWriter = getXmlWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (xmlWriter != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            // Store the cursor position before writing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            curPosBfrWrite = this.getRow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            xmlWriter.writeXML(this, writer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            throw new SQLException(resBundle.handleGetObject("webrowsetimpl.invalidwr").toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        }
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
     * Reads this <code>WebRowSet</code> object in its XML format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @throws SQLException if a database access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public void readXml(java.io.Reader reader) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        // %%%
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        // This will change to a XmlReader, which over-rides the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        // Xml that is used when a WRS is instantiated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        //WebRowSetXmlReader xmlReader = getXmlReader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
             if (reader != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                xmlReader.readXML(this, reader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                // Position is before the first row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                // The cursor position is to be stored while serializng
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                // and deserializing the WebRowSet Object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                if(curPosBfrWrite == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                   this.beforeFirst();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                // Return the position back to place prior to callin writeXml
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                   this.absolute(curPosBfrWrite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                throw new SQLException(resBundle.handleGetObject("webrowsetimpl.invalidrd").toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            throw new SQLException(e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    // Stream based methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Reads a stream based XML input to populate this <code>WebRowSet</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @throws SQLException if a data source access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @throws IOException if a IO exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public void readXml(java.io.InputStream iStream) throws SQLException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (iStream != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            xmlReader.readXML(this, iStream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            // Position is before the first row
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                // The cursor position is to be stored while serializng
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                // and deserializing the WebRowSet Object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                if(curPosBfrWrite == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                   this.beforeFirst();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                // Return the position back to place prior to callin writeXml
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                   this.absolute(curPosBfrWrite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            throw new SQLException(resBundle.handleGetObject("webrowsetimpl.invalidrd").toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * Writes this <code>WebRowSet</code> object to the given <code> OutputStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * object in XML format.
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 25859
diff changeset
   237
     * Creates an output stream of the internal state and contents of a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * <code>WebRowSet</code> for XML proceessing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @throws SQLException if a datasource access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @throws IOException if an IO exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public void writeXml(java.io.OutputStream oStream) throws SQLException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        if (xmlWriter != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            // Store the cursor position before writing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            curPosBfrWrite = this.getRow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            xmlWriter.writeXML(this, oStream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            throw new SQLException(resBundle.handleGetObject("webrowsetimpl.invalidwr").toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
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
     * Populates this <code>WebRowSet</code> object with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * data in the given <code>ResultSet</code> object and writes itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * to the given <code>java.io.OutputStream</code> object in XML format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * This includes the rowset's data,  properties, and metadata.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @throws SQLException if a datasource access error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @throws IOException if an IO exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public void writeXml(ResultSet rs, java.io.OutputStream oStream) throws SQLException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            this.populate(rs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            // Store the cursor position before writing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            curPosBfrWrite = this.getRow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            this.writeXml(oStream);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    }
6530
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   273
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   274
    /**
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   275
     * This method re populates the resBundle
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   276
     * during the deserialization process
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   277
     *
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   278
     */
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   279
    private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   280
        // Default state initialization happens here
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   281
        ois.defaultReadObject();
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   282
        // Initialization of transient Res Bundle happens here .
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   283
        try {
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   284
           resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   285
        } catch(IOException ioe) {
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   286
            throw new RuntimeException(ioe);
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   287
        }
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   288
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   289
    }
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   290
bfb7b294dd14 6680198: UnmarshalException caused by incompatible serialVersionUID
lancea
parents: 5506
diff changeset
   291
    static final long serialVersionUID = -8771775154092422943L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
}