summaryrefslogtreecommitdiff
path: root/java/sql
diff options
context:
space:
mode:
authorAaron M. Renn <arenn@urbanophile.com>1999-01-17 22:11:43 +0000
committerAaron M. Renn <arenn@urbanophile.com>1999-01-17 22:11:43 +0000
commitea6916243746fc632554f29840d55538f1171153 (patch)
treed117f1932c2bcb6e30f7c8fae705db04a34ef369 /java/sql
parente3be23f0e27ca0cb5e715bae372ef98a504b6760 (diff)
downloadclasspath-ea6916243746fc632554f29840d55538f1171153.tar.gz
Initial Checkin
Diffstat (limited to 'java/sql')
-rw-r--r--java/sql/SQLData.java68
-rw-r--r--java/sql/SQLInput.java326
-rw-r--r--java/sql/SQLOutput.java312
-rw-r--r--java/sql/Struct.java74
4 files changed, 780 insertions, 0 deletions
diff --git a/java/sql/SQLData.java b/java/sql/SQLData.java
new file mode 100644
index 000000000..09efa8720
--- /dev/null
+++ b/java/sql/SQLData.java
@@ -0,0 +1,68 @@
+/*************************************************************************
+/* SQLData.java -- Custom mapping for a user defined datatype
+/*
+/* Copyright (c) 1999 Free Software Foundation, Inc.
+/* Written by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This library is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU Library General Public License as published
+/* by the Free Software Foundation, either version 2 of the License, or
+/* (at your option) any later verion.
+/*
+/* This library 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 Library General Public License for more details.
+/*
+/* You should have received a copy of the GNU Library General Public License
+/* along with this library; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+package java.sql;
+
+/**
+ * This interface is used for mapping SQL data to user defined datatypes.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public abstract interface SQLData
+{
+
+/**
+ * This method returns the user defined datatype name for this object.
+ *
+ * @return The user defined data type name for this object.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract String
+getSQLTypeName() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method populates the data in the object from the specified stream.
+ *
+ * @param stream The stream to read the data from.
+ * @param name The data type name of the data on the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+readSQL(SQLInput stream, String name) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the data in this object to the specified stream.
+ *
+ * @param stream The stream to write the data to.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeSQL(SQLOutput stream) throws SQLException;
+
+} // interface SQLData
+
diff --git a/java/sql/SQLInput.java b/java/sql/SQLInput.java
new file mode 100644
index 000000000..9b247775e
--- /dev/null
+++ b/java/sql/SQLInput.java
@@ -0,0 +1,326 @@
+/*************************************************************************
+/* SQLInput.java -- Read SQL values from a stream
+/*
+/* Copyright (c) 1999 Free Software Foundation, Inc.
+/* Written by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This library is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU Library General Public License as published
+/* by the Free Software Foundation, either version 2 of the License, or
+/* (at your option) any later verion.
+/*
+/* This library 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 Library General Public License for more details.
+/*
+/* You should have received a copy of the GNU Library General Public License
+/* along with this library; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+package java.sql;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+
+/**
+ * This interface provides methods for reading values from a stream
+ * that is connected to a SQL structured or distinct type. It is used
+ * for custom mapping of user defined data types.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public abstract interface SQLInput
+{
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>String</code>.
+ *
+ * @return The value read from the stream as a <code>String</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract String
+readString() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>boolean</code>.
+ *
+ * @return The value read from the stream as a <code>boolean</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract boolean
+readBoolean() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>byte</code>.
+ *
+ * @return The value read from the stream as a <code>byte</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract byte
+readByte() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>short</code>.
+ *
+ * @return The value read from the stream as a <code>short</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract short
+readShort() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>int</code>.
+ *
+ * @return The value read from the stream as an <code>int</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract int
+readInt() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>long</code>.
+ *
+ * @return The value read from the stream as a <code>long</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract long
+readLong() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>float</code>.
+ *
+ * @return The value read from the stream as a <code>float</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract float
+readFloat() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>double</code>.
+ *
+ * @return The value read from the stream as a <code>double</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract double
+readDouble() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>BigDecimal</code>.
+ *
+ * @return The value read from the stream as a <code>BigDecimal</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract BigDecimal
+readBigDecimal() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * byte array
+ *
+ * @return The value read from the stream as a byte array.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract byte[]
+readBytes() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>java.sql.Date</code>.
+ *
+ * @return The value read from the stream as a <code>java.sql.Date</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract java.sql.Date
+readDate() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>java.sql.Time</code>.
+ *
+ * @return The value read from the stream as a <code>java.sql.Time</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract java.sql.Time
+readTime() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>java.sql.Timestamp</code>.
+ *
+ * @return The value read from the stream as a <code>java.sql.Timestamp</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract java.sql.Timestamp
+readTimestamp() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a ASCII text
+ * <code>InputStream</code>.
+ *
+ * @return The value read from the stream as an <code>InputStream</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract InputStream
+readAsciiStream() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a binary
+ * <code>InputStream</code>.
+ *
+ * @return The value read from the stream as an <code>InputStream</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract InputStream
+readBinaryStream() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a character
+ * <code>Reader</code>.
+ *
+ * @return The value read from the stream as a <code>Reader</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract Reader
+readCharacterStream() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java
+ * <code>Object</code>.
+ *
+ * @return The value read from the stream as an <code>Object</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract Object
+readObject() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java SQL
+ * <code>Ref</code>.
+ *
+ * @return The value read from the stream as an <code>Ref</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract Ref
+readRef() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java SQL
+ * <code>Blob</code>.
+ *
+ * @return The value read from the stream as a <code>Blob</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract Blob
+readBlob() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java SQL
+ * <code>Clob</code>.
+ *
+ * @return The value read from the stream as a <code>Clob</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract Clob
+readClob() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method reads the next item from the stream a Java SQL
+ * <code>Array</code>.
+ *
+ * @return The value read from the stream as an <code>Array</code>.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract Array
+readArray() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method tests whether or not the last value read was a SQL
+ * NULL value.
+ *
+ * @return <code>true</code> if the last value read was a NULL,
+ * <code>false</code> otherwise.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract boolean
+wasNull() throws SQLException;
+
+} // interface SQLInput
+
diff --git a/java/sql/SQLOutput.java b/java/sql/SQLOutput.java
new file mode 100644
index 000000000..92068bd98
--- /dev/null
+++ b/java/sql/SQLOutput.java
@@ -0,0 +1,312 @@
+/*************************************************************************
+/* SQLOutput.java -- Write SQL values to a stream
+/*
+/* Copyright (c) 1999 Free Software Foundation, Inc.
+/* Written by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This library is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU Library General Public License as published
+/* by the Free Software Foundation, either version 2 of the License, or
+/* (at your option) any later verion.
+/*
+/* This library 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 Library General Public License for more details.
+/*
+/* You should have received a copy of the GNU Library General Public License
+/* along with this library; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+package java.sql;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+
+/**
+ * This interface provides methods for writing Java types to a SQL stream.
+ * It is used for implemented custom type mappings for user defined data
+ * types.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public abstract interface SQLOutput
+{
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>String</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeString(String value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>boolean</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeBoolean(boolean value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>byte</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeByte(byte value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>short</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeShort(short value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>int</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeInt(int value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>long</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeLong(long value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>float</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeFloat(float value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>double</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeDouble(double value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>BigDecimal</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeBigDecimal(BigDecimal value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>byte</code> array
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeBytes(byte[] value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>java.sql.Date</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeDate(java.sql.Date value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>java.sql.Time</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeTime(java.sql.Time value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>java.sql.Timestamp</code>
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeTimestamp(java.sql.Timestamp value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java character stream
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeCharacterStream(Reader value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified ASCII text stream
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeBinaryStream(InputStream value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java <code>SQLData</code> object
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeObject(SQLData value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java SQL <code>Ref</code> object
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeRef(Ref value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java SQL <code>Blob</code> object
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeBlob(Blob value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java SQL <code>Clob</code> object
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeClob(Clob value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java SQL <code>Struct</code> object
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeStruct(Struct value) throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method writes the specified Java SQL <code>Array</code> object
+ * to the SQL stream.
+ *
+ * @param value The value to write to the stream.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract void
+writeArray(Array value) throws SQLException;
+
+} // interface SQLOutput
+
diff --git a/java/sql/Struct.java b/java/sql/Struct.java
new file mode 100644
index 000000000..5fa3c13a0
--- /dev/null
+++ b/java/sql/Struct.java
@@ -0,0 +1,74 @@
+/*************************************************************************
+/* Struct.java -- Mapping for a SQL structured type.
+/*
+/* Copyright (c) 1999 Free Software Foundation, Inc.
+/* Written by Aaron M. Renn (arenn@urbanophile.com)
+/*
+/* This library is free software; you can redistribute it and/or modify
+/* it under the terms of the GNU Library General Public License as published
+/* by the Free Software Foundation, either version 2 of the License, or
+/* (at your option) any later verion.
+/*
+/* This library 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 Library General Public License for more details.
+/*
+/* You should have received a copy of the GNU Library General Public License
+/* along with this library; if not, write to the Free Software Foundation
+/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
+/*************************************************************************/
+
+package java.sql;
+
+import java.util.Map;
+
+/**
+ * This interface implements the standard type mapping for a SQL
+ * structured type.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public abstract interface Struct
+{
+
+/**
+ * This method returns the name of the SQL structured type for this
+ * object.
+ *
+ * @return The SQL structured type name.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract String
+getSQLTypeName() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method returns the attributes of this SQL structured type.
+ *
+ * @return The attributes of this structure type.
+ *
+ * @exception SQLException If an error occurs.
+ */
+public abstract Object[]
+getAttributes() throws SQLException;
+
+/*************************************************************************/
+
+/**
+ * This method returns the attributes of this SQL structured type.
+ * The specified map of type mappings overrides the default mappings.
+ *
+ * @param map The map of SQL type mappings.
+ *
+ * @return The attributes of this structure type.
+ *
+ * @exception SQLException If a error occurs.
+ */
+public abstract Object[]
+getAttributes(Map map) throws SQLException;
+
+} // interface Struct
+