/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The standard implementation of the <code>WebRowSet</code> interface. See the interface
* defintion for full behaviour and implementation requirements.
*
* @author Jonathan Bruce, Amit Handa
*/
/**
* The <code>WebRowSetXmlReader</code> object that this
* <code>WebRowSet</code> object will call when the method
* <code>WebRowSet.readXml</code> is invoked.
*/
/**
* The <code>WebRowSetXmlWriter</code> object that this
* <code>WebRowSet</code> object will call when the method
* <code>WebRowSet.writeXml</code> is invoked.
*/
/* This stores the cursor position prior to calling the writeXML.
* This variable is used after the write to restore the position
* to the point where the writeXml was called.
*/
private int curPosBfrWrite;
/**
* Constructs a new <code>WebRowSet</code> object initialized with the
* default values for a <code>CachedRowSet</code> object instance. This
* provides the <code>RIOptimistic</code> provider to deliver
* synchronization capabilities to relational datastores and a default
* <code>WebRowSetXmlReader</code> object and a default
* <code>WebRowSetXmlWriter</code> object to enable XML output
* capabilities.
*
* @throws SQLException if an error occurs in configuring the default
* synchronization providers for relational and XML providers.
*/
super();
// %%%
// Needs to use to SPI XmlReader,XmlWriters
//
xmlReader = new WebRowSetXmlReader();
xmlWriter = new WebRowSetXmlWriter();
}
/**
* Constructs a new <code>WebRowSet</code> object initialized with the the
* synchronization SPI provider properties as specified in the <code>Hashtable</code>. If
* this hashtable is empty or is <code>null</code> the default constructor is invoked.
*
* @throws SQLException if an error occurs in configuring the specified
* synchronization providers for the relational and XML providers; or
* if the Hashtanle is null
*/
try {
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
// set the Reader, this maybe overridden latter
// xmlReader = provider.getRowSetReader();
// xmlWriter = provider.getRowSetWriter();
}
/**
* Populates this <code>WebRowSet</code> object with the
* data in the given <code>ResultSet</code> object and writes itself
* to the given <code>java.io.Writer</code> object in XML format.
* This includes the rowset's data, properties, and metadata.
*
* @throws SQLException if an error occurs writing out the rowset
* contents to XML
*/
throws SQLException {
// WebRowSetImpl wrs = new WebRowSetImpl();
// Store the cursor position before writing
curPosBfrWrite = this.getRow();
}
/**
* Writes this <code>WebRowSet</code> object to the given
* <code>java.io.Writer</code> object in XML format. This
* includes the rowset's data, properties, and metadata.
*
* @throws SQLException if an error occurs writing out the rowset
* contents to XML
*/
// %%%
// This will change to a XmlReader, which over-rides the default
// Xml that is used when a WRS is instantiated.
// WebRowSetXmlWriter xmlWriter = getXmlWriter();
// Store the cursor position before writing
curPosBfrWrite = this.getRow();
} else {
}
}
/**
* Reads this <code>WebRowSet</code> object in its XML format.
*
* @throws SQLException if a database access error occurs
*/
// %%%
// This will change to a XmlReader, which over-rides the default
// Xml that is used when a WRS is instantiated.
//WebRowSetXmlReader xmlReader = getXmlReader();
try {
// Position is before the first row
// The cursor position is to be stored while serializng
// and deserializing the WebRowSet Object.
if(curPosBfrWrite == 0) {
this.beforeFirst();
}
// Return the position back to place prior to callin writeXml
else {
this.absolute(curPosBfrWrite);
}
} else {
}
} catch (Exception e) {
throw new SQLException(e.getMessage());
}
}
// Stream based methods
/**
* Reads a stream based XML input to populate this <code>WebRowSet</code>
* object.
*
* @throws SQLException if a data source access error occurs
* @throws IOException if a IO exception occurs
*/
// Position is before the first row
// The cursor position is to be stored while serializng
// and deserializing the WebRowSet Object.
if(curPosBfrWrite == 0) {
this.beforeFirst();
}
// Return the position back to place prior to callin writeXml
else {
this.absolute(curPosBfrWrite);
}
} else {
}
}
/**
* Writes this <code>WebRowSet</code> object to the given <code> OutputStream</code>
* object in XML format.
* Creates an an output stream of the internal state and contents of a
* <code>WebRowSet</code> for XML proceessing
*
* @throws SQLException if a datasource access error occurs
* @throws IOException if an IO exception occurs
*/
// Store the cursor position before writing
curPosBfrWrite = this.getRow();
} else {
}
}
/**
* Populates this <code>WebRowSet</code> object with the
* data in the given <code>ResultSet</code> object and writes itself
* to the given <code>java.io.OutputStream</code> object in XML format.
* This includes the rowset's data, properties, and metadata.
*
* @throws SQLException if a datasource access error occurs
* @throws IOException if an IO exception occurs
*/
// Store the cursor position before writing
curPosBfrWrite = this.getRow();
}
/**
* This method re populates the resBundle
* during the deserialization process
*
*/
// Default state initialization happens here
// Initialization of transient Res Bundle happens here .
try {
} catch(IOException ioe) {
throw new RuntimeException(ioe);
}
}
}