// Path: domsql/eclipse/plugins/com.ibm.domino.domsql.driver/src/com/ibm/domino/domsql/remote/transport/SInputStream.java
// public class SInputStream extends SerializableObject {
// 	
// 	private static final long serialVersionUID = 1L;
// 	
// 	public static SInputStream create(InputStream w) {
// 		throw new IllegalStateException();
// 	}
// 	public static InputStream getInputStream(SInputStream w) {
// 		throw new IllegalStateException();
// 	}
// 	public static byte[] getByteArray(SInputStream w) {
// 		throw new IllegalStateException();
// 	}
// 	
// 	private SInputStream() {
// 		// should be public for serialization...
// 		throw new IllegalStateException();
// 	}
// }
// 
// Path: domsql/eclipse/plugins/com.ibm.domino.domsql.driver/src/com/ibm/domino/domsql/remote/transport/SReader.java
// public class SReader extends SerializableObject {
// 	
// 	private static final long serialVersionUID = 1L;
// 	
// 	public static SReader create(Reader w) {
// 		throw new IllegalStateException();
// 	}
// 	public static Reader getReader(SReader w) {
// 		throw new IllegalStateException();
// 	}
// 	
// 	private SReader() {
// 		// should be public for serialization...
// 		throw new IllegalStateException();
// 	}
// }


import com.ibm.domino.domsql.remote.transport.SInputStream;
import com.ibm.domino.domsql.remote.transport.SReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.util.Calendar;

	public static byte[] toByteArray(Object o) throws SQLException {
		if(o==null) {
			return null;
		}
		if(o instanceof byte[]) {
			return (byte[])o;
		}
		if(o instanceof SInputStream) {
			return SInputStream.getByteArray((SInputStream)o);
		}
		if(o instanceof InputStream) {
			try {
				InputStream is = (InputStream)o;
				ByteArrayOutputStream os = new ByteArrayOutputStream();
				byte[] buffer = new byte[4096];
				int readBytes;
				while( (readBytes = is.read(buffer))>0 ) {
					os.write(buffer, 0, readBytes);
				}
				return os.toByteArray();
			} catch(IOException e) {
				throw new SQLException(e);
			}
		}
		throw conversionError();
	}
	public static Reader toReader(Object o) throws SQLException {
		if(o==null) {
			return null;
		}

// Path: domsql/eclipse/plugins/com.ibm.domino.domsql.driver/src/com/ibm/domino/domsql/remote/transport/SInputStream.java
// public class SInputStream extends SerializableObject {
// 	
// 	private static final long serialVersionUID = 1L;
// 	
// 	public static SInputStream create(InputStream w) {
// 		throw new IllegalStateException();
// 	}
// 	public static InputStream getInputStream(SInputStream w) {
// 		throw new IllegalStateException();
// 	}
// 	public static byte[] getByteArray(SInputStream w) {
// 		throw new IllegalStateException();
// 	}
// 	
// 	private SInputStream() {
// 		// should be public for serialization...
// 		throw new IllegalStateException();
// 	}
// }
// 
// Path: domsql/eclipse/plugins/com.ibm.domino.domsql.driver/src/com/ibm/domino/domsql/remote/transport/SReader.java
// public class SReader extends SerializableObject {
// 	
// 	private static final long serialVersionUID = 1L;
// 	
// 	public static SReader create(Reader w) {
// 		throw new IllegalStateException();
// 	}
// 	public static Reader getReader(SReader w) {
// 		throw new IllegalStateException();
// 	}
// 	
// 	private SReader() {
// 		// should be public for serialization...
// 		throw new IllegalStateException();
// 	}
// }


// Path: domsql/eclipse/plugins/com.ibm.domino.domsql.driver/src/com/ibm/domino/domsql/remote/client/DataConverter.java
import com.ibm.domino.domsql.remote.transport.SInputStream;
import com.ibm.domino.domsql.remote.transport.SReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.util.Calendar;

	public static byte[] toByteArray(Object o) throws SQLException {
		if(o==null) {
			return null;
		}
		if(o instanceof byte[]) {
			return (byte[])o;
		}
		if(o instanceof SInputStream) {
			return SInputStream.getByteArray((SInputStream)o);
		}
		if(o instanceof InputStream) {
			try {
				InputStream is = (InputStream)o;
				ByteArrayOutputStream os = new ByteArrayOutputStream();
				byte[] buffer = new byte[4096];
				int readBytes;
				while( (readBytes = is.read(buffer))>0 ) {
					os.write(buffer, 0, readBytes);
				}
				return os.toByteArray();
			} catch(IOException e) {
				throw new SQLException(e);
			}
		}
		throw conversionError();
	}
	public static Reader toReader(Object o) throws SQLException {
		if(o==null) {
			return null;
		}

		if(o instanceof SReader) {
