1 /*
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
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 package javax.sql.rowset.serial;
26
27 import java.sql.*;
28 import java.util.Arrays;
29 import java.util.Map;
30
31 /**
32 * An input stream used for custom mapping user-defined types (UDTs).
33 * An <code>SQLInputImpl</code> object is an input stream that contains a
34 * stream of values that are the attributes of a UDT.
35 * <p>
36 * This class is used by the driver behind the scenes when the method
37 * <code>getObject</code> is called on an SQL structured or distinct type
38 * that has a custom mapping; a programmer never invokes
39 * <code>SQLInputImpl</code> methods directly. They are provided here as a
40 * convenience for those who write <code>RowSet</code> implementations.
41 * <P>
42 * The <code>SQLInputImpl</code> class provides a set of
43 * reader methods analogous to the <code>ResultSet</code> getter
44 * methods. These methods make it possible to read the values in an
45 * <code>SQLInputImpl</code> object.
46 * <P>
749 }
750
751 /**
752 * Reads an SQL <code>DATALINK</code> value from the stream and
753 * returns it as an <code>URL</code> object in the Java programming
754 * language.
755 * <P>
756 * This method does not perform type-safe checking to determine if the
757 * returned type is the expected type as this responsibility is delegated
758 * to the UDT mapping as implemented by a <code>SQLData</code>
759 * implementation.
760 *
761 * @return an <code>URL</code> object representing the SQL
762 * <code>DATALINK</code> value at the head of the stream; *
763 * if the value is <code>SQL NULL</code>, return
764 * <code>null</code>
765 * @throws SQLException if the read position is located at an invalid
766 * position; or if there are no further values in the stream.
767 */
768 public java.net.URL readURL() throws SQLException {
769 throw new SQLException("Operation not supported");
770 }
771
772 //---------------------------- JDBC 4.0 -------------------------
773
774 /**
775 * Reads an SQL <code>NCLOB</code> value from the stream and returns it as a
776 * <code>Clob</code> object in the Java programming language.
777 *
778 * @return a <code>NClob</code> object representing data of the SQL <code>NCLOB</code> value
779 * at the head of the stream; <code>null</code> if the value read is
780 * SQL <code>NULL</code>
781 * @exception SQLException if a database access error occurs
782 */
783 public NClob readNClob() throws SQLException {
784 throw new UnsupportedOperationException("Operation not supported");
785 }
786
787 /**
788 * Reads the next attribute in the stream and returns it as a <code>String</code>
789 * in the Java programming language. It is intended for use when
790 * accessing <code>NCHAR</code>,<code>NVARCHAR</code>
791 * and <code>LONGNVARCHAR</code> columns.
792 *
793 * @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
794 * @exception SQLException if a database access error occurs
795 */
796 public String readNString() throws SQLException {
797 throw new UnsupportedOperationException("Operation not supported");
798 }
799
800 /**
801 * Reads an SQL <code>XML</code> value from the stream and returns it as a
802 * <code>SQLXML</code> object in the Java programming language.
803 *
804 * @return a <code>SQLXML</code> object representing data of the SQL <code>XML</code> value
805 * at the head of the stream; <code>null</code> if the value read is
806 * SQL <code>NULL</code>
807 * @exception SQLException if a database access error occurs
808 */
809 public SQLXML readSQLXML() throws SQLException {
810 throw new UnsupportedOperationException("Operation not supported");
811 }
812
813 /**
814 * Reads an SQL <code>ROWID</code> value from the stream and returns it as a
815 * <code>RowId</code> object in the Java programming language.
816 *
817 * @return a <code>RowId</code> object representing data of the SQL <code>ROWID</code> value
818 * at the head of the stream; <code>null</code> if the value read is
819 * SQL <code>NULL</code>
820 * @exception SQLException if a database access error occurs
821 */
822 public RowId readRowId() throws SQLException {
823 throw new UnsupportedOperationException("Operation not supported");
824 }
825
826
827 }
|
1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
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 package javax.sql.rowset.serial;
26
27 import java.net.URL;
28 import java.sql.*;
29 import java.util.Arrays;
30 import java.util.Map;
31
32 /**
33 * An input stream used for custom mapping user-defined types (UDTs).
34 * An <code>SQLInputImpl</code> object is an input stream that contains a
35 * stream of values that are the attributes of a UDT.
36 * <p>
37 * This class is used by the driver behind the scenes when the method
38 * <code>getObject</code> is called on an SQL structured or distinct type
39 * that has a custom mapping; a programmer never invokes
40 * <code>SQLInputImpl</code> methods directly. They are provided here as a
41 * convenience for those who write <code>RowSet</code> implementations.
42 * <P>
43 * The <code>SQLInputImpl</code> class provides a set of
44 * reader methods analogous to the <code>ResultSet</code> getter
45 * methods. These methods make it possible to read the values in an
46 * <code>SQLInputImpl</code> object.
47 * <P>
750 }
751
752 /**
753 * Reads an SQL <code>DATALINK</code> value from the stream and
754 * returns it as an <code>URL</code> object in the Java programming
755 * language.
756 * <P>
757 * This method does not perform type-safe checking to determine if the
758 * returned type is the expected type as this responsibility is delegated
759 * to the UDT mapping as implemented by a <code>SQLData</code>
760 * implementation.
761 *
762 * @return an <code>URL</code> object representing the SQL
763 * <code>DATALINK</code> value at the head of the stream; *
764 * if the value is <code>SQL NULL</code>, return
765 * <code>null</code>
766 * @throws SQLException if the read position is located at an invalid
767 * position; or if there are no further values in the stream.
768 */
769 public java.net.URL readURL() throws SQLException {
770 URL attrib = (URL)getNextAttribute();
771
772 if (attrib == null) {
773 lastValueWasNull = true;
774 return null;
775 } else {
776 lastValueWasNull = false;
777 return attrib;
778 }
779 }
780
781 //---------------------------- JDBC 4.0 -------------------------
782
783 /**
784 * Reads an SQL <code>NCLOB</code> value from the stream and returns it as a
785 * <code>Clob</code> object in the Java programming language.
786 *
787 * @return a <code>NClob</code> object representing data of the SQL <code>NCLOB</code> value
788 * at the head of the stream; <code>null</code> if the value read is
789 * SQL <code>NULL</code>
790 * @exception SQLException if a database access error occurs
791 */
792 public NClob readNClob() throws SQLException {
793 NClob attrib = (NClob)getNextAttribute();
794 if (attrib == null) {
795 lastValueWasNull = true;
796 return null;
797 } else {
798 lastValueWasNull = false;
799 return attrib;
800 } }
801
802 /**
803 * Reads the next attribute in the stream and returns it as a <code>String</code>
804 * in the Java programming language. It is intended for use when
805 * accessing <code>NCHAR</code>,<code>NVARCHAR</code>
806 * and <code>LONGNVARCHAR</code> columns.
807 *
808 * @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
809 * @exception SQLException if a database access error occurs
810 */
811 public String readNString() throws SQLException {
812 String attrib = (String)getNextAttribute();
813
814 if (attrib == null) {
815 lastValueWasNull = true;
816 return null;
817 } else {
818 lastValueWasNull = false;
819 return attrib;
820 } }
821
822 /**
823 * Reads an SQL <code>XML</code> value from the stream and returns it as a
824 * <code>SQLXML</code> object in the Java programming language.
825 *
826 * @return a <code>SQLXML</code> object representing data of the SQL <code>XML</code> value
827 * at the head of the stream; <code>null</code> if the value read is
828 * SQL <code>NULL</code>
829 * @exception SQLException if a database access error occurs
830 */
831 public SQLXML readSQLXML() throws SQLException {
832 SQLXML attrib = (SQLXML)getNextAttribute();
833 if (attrib == null) {
834 lastValueWasNull = true;
835 return null;
836 } else {
837 lastValueWasNull = false;
838 return attrib;
839 } }
840
841 /**
842 * Reads an SQL <code>ROWID</code> value from the stream and returns it as a
843 * <code>RowId</code> object in the Java programming language.
844 *
845 * @return a <code>RowId</code> object representing data of the SQL <code>ROWID</code> value
846 * at the head of the stream; <code>null</code> if the value read is
847 * SQL <code>NULL</code>
848 * @exception SQLException if a database access error occurs
849 */
850 public RowId readRowId() throws SQLException {
851 RowId attrib = (RowId)getNextAttribute();
852 if (attrib == null) {
853 lastValueWasNull = true;
854 return null;
855 } else {
856 lastValueWasNull = false;
857 return attrib;
858 }
859 }
860
861
862 }
|