19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.rowset.internal; 27 28 import com.sun.rowset.JdbcRowSetResourceBundle; 29 import java.sql.*; 30 import javax.sql.*; 31 import java.io.*; 32 import java.text.MessageFormat; 33 import java.util.*; 34 35 import javax.sql.rowset.*; 36 import javax.sql.rowset.spi.*; 37 38 /** 39 * An implementation of the <code>XmlWriter</code> interface, which writes a 40 * <code>WebRowSet</code> object to an output stream as an XML document. 41 */ 42 43 public class WebRowSetXmlWriter implements XmlWriter, Serializable { 44 45 /** 46 * The <code>java.io.Writer</code> object to which this <code>WebRowSetXmlWriter</code> 47 * object will write when its <code>writeXML</code> method is called. The value 48 * for this field is set with the <code>java.io.Writer</code> object given 49 * as the second argument to the <code>writeXML</code> method. 50 */ 51 private transient java.io.Writer writer; 52 53 /** 54 * The <code>java.util.Stack</code> object that this <code>WebRowSetXmlWriter</code> 55 * object will use for storing the tags to be used for writing the calling 56 * <code>WebRowSet</code> object as an XML document. 57 */ 58 private java.util.Stack<String> stack; 59 60 private JdbcRowSetResourceBundle resBundle; 61 62 public WebRowSetXmlWriter() { 63 64 try { 65 resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); 66 } catch(IOException ioe) { 67 throw new RuntimeException(ioe); 68 } 69 } 70 71 /** 72 * Writes the given <code>WebRowSet</code> object as an XML document 73 * using the given <code>java.io.Writer</code> object. The XML document 74 * will include the <code>WebRowSet</code> object's data, metadata, and 75 * properties. If a data value has been updated, that information is also 76 * included. 77 * <P> 78 * This method is called by the <code>XmlWriter</code> object that is 79 * referenced in the calling <code>WebRowSet</code> object's 80 * <code>xmlWriter</code> field. The <code>XmlWriter.writeXML</code> 81 * method passes to this method the arguments that were supplied to it. 82 * 83 * @param caller the <code>WebRowSet</code> object to be written; must 84 * be a rowset for which this <code>WebRowSetXmlWriter</code> object 85 * is the writer 86 * @param wrt the <code>java.io.Writer</code> object to which 87 * <code>caller</code> will be written 88 * @exception SQLException if a database access error occurs or 89 * this <code>WebRowSetXmlWriter</code> object is not the writer 90 * for the given rowset 91 * @see XmlWriter#writeXML 92 */ 93 public void writeXML(WebRowSet caller, java.io.Writer wrt) 94 throws SQLException { 95 96 // create a new stack for tag checking. 97 stack = new java.util.Stack<>(); 98 writer = wrt; 99 writeRowSet(caller); 100 } 101 102 /** 103 * Writes the given <code>WebRowSet</code> object as an XML document 104 * using the given <code>java.io.OutputStream</code> object. The XML document 105 * will include the <code>WebRowSet</code> object's data, metadata, and 106 * properties. If a data value has been updated, that information is also 107 * included. 108 * <P> 109 * Using stream is a faster way than using <code>java.io.Writer<code/> 110 * 111 * This method is called by the <code>XmlWriter</code> object that is 112 * referenced in the calling <code>WebRowSet</code> object's 113 * <code>xmlWriter</code> field. The <code>XmlWriter.writeXML</code> 114 * method passes to this method the arguments that were supplied to it. 115 * 116 * @param caller the <code>WebRowSet</code> object to be written; must 117 * be a rowset for which this <code>WebRowSetXmlWriter</code> object 118 * is the writer 119 * @param oStream the <code>java.io.OutputStream</code> object to which 120 * <code>caller</code> will be written 121 * @throws SQLException if a database access error occurs or 122 * this <code>WebRowSetXmlWriter</code> object is not the writer 123 * for the given rowset 124 * @see XmlWriter#writeXML 125 */ 126 public void writeXML(WebRowSet caller, java.io.OutputStream oStream) 127 throws SQLException { 128 129 // create a new stack for tag checking. 130 stack = new java.util.Stack<>(); 131 writer = new OutputStreamWriter(oStream); 132 writeRowSet(caller); 133 } 134 135 /** 136 * 137 * 138 * @exception SQLException if a database access error occurs 139 */ 140 private void writeRowSet(WebRowSet caller) throws SQLException { 141 142 try { | 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.rowset.internal; 27 28 import com.sun.rowset.JdbcRowSetResourceBundle; 29 import java.sql.*; 30 import javax.sql.*; 31 import java.io.*; 32 import java.text.MessageFormat; 33 import java.util.*; 34 35 import javax.sql.rowset.*; 36 import javax.sql.rowset.spi.*; 37 38 /** 39 * An implementation of the {@code XmlWriter} interface, which writes a 40 * {@code WebRowSet} object to an output stream as an XML document. 41 */ 42 43 public class WebRowSetXmlWriter implements XmlWriter, Serializable { 44 45 /** 46 * The {@code java.io.Writer} object to which this {@code WebRowSetXmlWriter} 47 * object will write when its {@code writeXML} method is called. The value 48 * for this field is set with the {@code java.io.Writer} object given 49 * as the second argument to the {@code writeXML} method. 50 */ 51 private transient java.io.Writer writer; 52 53 /** 54 * The {@code java.util.Stack} object that this {@code WebRowSetXmlWriter} 55 * object will use for storing the tags to be used for writing the calling 56 * {@code WebRowSet} object as an XML document. 57 */ 58 private java.util.Stack<String> stack; 59 60 private JdbcRowSetResourceBundle resBundle; 61 62 public WebRowSetXmlWriter() { 63 64 try { 65 resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); 66 } catch(IOException ioe) { 67 throw new RuntimeException(ioe); 68 } 69 } 70 71 /** 72 * Writes the given {@code WebRowSet} object as an XML document 73 * using the given {@code java.io.Writer} object. The XML document 74 * will include the {@code WebRowSet} object's data, metadata, and 75 * properties. If a data value has been updated, that information is also 76 * included. 77 * <P> 78 * This method is called by the {@code XmlWriter} object that is 79 * referenced in the calling {@code WebRowSet} object's 80 * {@code xmlWriter} field. The {@code XmlWriter.writeXML} 81 * method passes to this method the arguments that were supplied to it. 82 * 83 * @param caller the {@code WebRowSet} object to be written; must 84 * be a rowset for which this {@code WebRowSetXmlWriter} object 85 * is the writer 86 * @param wrt the {@code java.io.Writer} object to which 87 * {@code caller} will be written 88 * @exception SQLException if a database access error occurs or 89 * this {@code WebRowSetXmlWriter} object is not the writer 90 * for the given rowset 91 * @see XmlWriter#writeXML 92 */ 93 public void writeXML(WebRowSet caller, java.io.Writer wrt) 94 throws SQLException { 95 96 // create a new stack for tag checking. 97 stack = new java.util.Stack<>(); 98 writer = wrt; 99 writeRowSet(caller); 100 } 101 102 /** 103 * Writes the given {@code WebRowSet} object as an XML document 104 * using the given {@code java.io.OutputStream} object. The XML document 105 * will include the {@code WebRowSet} object's data, metadata, and 106 * properties. If a data value has been updated, that information is also 107 * included. 108 * <P> 109 * Using stream is a faster way than using {@code java.io.Writer} 110 * 111 * This method is called by the {@code XmlWriter} object that is 112 * referenced in the calling {@code WebRowSet} object's 113 * {@code xmlWriter} field. The {@code XmlWriter.writeXML} 114 * method passes to this method the arguments that were supplied to it. 115 * 116 * @param caller the {@code WebRowSet} object to be written; must 117 * be a rowset for which this {@code WebRowSetXmlWriter} object 118 * is the writer 119 * @param oStream the {@code java.io.OutputStream} object to which 120 * {@code caller} will be written 121 * @throws SQLException if a database access error occurs or 122 * this {@code WebRowSetXmlWriter} object is not the writer 123 * for the given rowset 124 * @see XmlWriter#writeXML 125 */ 126 public void writeXML(WebRowSet caller, java.io.OutputStream oStream) 127 throws SQLException { 128 129 // create a new stack for tag checking. 130 stack = new java.util.Stack<>(); 131 writer = new OutputStreamWriter(oStream); 132 writeRowSet(caller); 133 } 134 135 /** 136 * 137 * 138 * @exception SQLException if a database access error occurs 139 */ 140 private void writeRowSet(WebRowSet caller) throws SQLException { 141 142 try { |