[teiid-commits] teiid SVN: r1032 - in trunk: client-jdbc/src/test/java/com/metamatrix/jdbc and 6 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Jun 9 14:11:52 EDT 2009


Author: shawkins
Date: 2009-06-09 14:11:52 -0400 (Tue, 09 Jun 2009)
New Revision: 1032

Removed:
   trunk/common-core/src/main/java/com/metamatrix/common/types/BlobImpl.java
   trunk/common-core/src/main/java/com/metamatrix/common/types/ClobImpl.java
   trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobImpl.java
   trunk/common-core/src/test/java/com/metamatrix/common/types/TestClobImpl.java
Modified:
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMBlob.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMClob.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestDataTypeTransformer.java
   trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java
   trunk/common-core/src/main/java/com/metamatrix/common/types/ClobType.java
   trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
   trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToClobTransform.java
   trunk/common-core/src/main/java/com/metamatrix/core/util/FileUtil.java
   trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java
   trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobValue.java
   trunk/common-core/src/test/java/com/metamatrix/common/types/TestClobValue.java
   trunk/common-core/src/test/java/com/metamatrix/common/types/TestDataTypeManager.java
   trunk/common-core/src/test/java/com/metamatrix/common/types/TestSQLXMLImpl.java
   trunk/common-core/src/test/java/com/metamatrix/common/types/TestXMLStreamSourceTranslator.java
   trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
   trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java
Log:
TEIID-649 refactoring to use jsr 114 blob and clob impls

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMBlob.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMBlob.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMBlob.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -28,8 +28,9 @@
 import java.sql.Blob;
 import java.sql.SQLException;
 
+import javax.sql.rowset.serial.SerialBlob;
+
 import com.metamatrix.common.lob.LobChunkInputStream;
-import com.metamatrix.common.types.BlobImpl;
 import com.metamatrix.common.types.BlobType;
 import com.metamatrix.common.types.Streamable;
 import com.metamatrix.common.util.SqlUtil;
@@ -181,7 +182,7 @@
     	if (pattern == null) {
     		return -1;
     	}
-        return position(new BlobImpl(pattern), start);
+        return position(new SerialBlob(pattern), start);
     }
         
 	public void free() throws SQLException {

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMClob.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMClob.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMClob.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -31,9 +31,10 @@
 import java.sql.Clob;
 import java.sql.SQLException;
 
+import javax.sql.rowset.serial.SerialClob;
+
 import com.metamatrix.common.lob.LobChunkInputStream;
 import com.metamatrix.common.lob.ReaderInputStream;
-import com.metamatrix.common.types.ClobImpl;
 import com.metamatrix.common.types.ClobType;
 import com.metamatrix.common.types.Streamable;
 import com.metamatrix.common.util.SqlUtil;
@@ -194,7 +195,7 @@
     	if (searchstr == null) {
             return -1;
         }
-    	return position(new ClobImpl(searchstr.toCharArray()), start);
+    	return position(new SerialClob(searchstr.toCharArray()), start);
     }
     	    
 	public void free() throws SQLException {

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMPreparedStatement.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -22,31 +22,23 @@
 
 package com.metamatrix.jdbc;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
 import java.math.BigDecimal;
 import java.net.URL;
-import java.nio.charset.Charset;
 import java.sql.Array;
 import java.sql.Blob;
 import java.sql.Clob;
+import java.sql.NClob;
 import java.sql.ParameterMetaData;
 import java.sql.PreparedStatement;
 import java.sql.Ref;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
+import java.sql.RowId;
 import java.sql.SQLException;
-
-//## JDBC4.0-begin ##
 import java.sql.SQLXML;
-import java.sql.NClob;
-import java.sql.RowId;
-//## JDBC4.0-end ##
-
-/*## JDBC3.0-JDK1.5-begin ##
-import com.metamatrix.core.jdbc.SQLXML; 
-## JDBC3.0-JDK1.5-end ##*/
-
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -56,14 +48,16 @@
 import java.util.TimeZone;
 import java.util.TreeMap;
 
+import javax.sql.rowset.serial.SerialBlob;
+import javax.sql.rowset.serial.SerialClob;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.types.BlobImpl;
-import com.metamatrix.common.types.ClobImpl;
 import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
 import com.metamatrix.common.util.SqlUtil;
 import com.metamatrix.common.util.TimestampWithTimezone;
 import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.util.ObjectConverterUtil;
 import com.metamatrix.dqp.client.MetadataResult;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.jdbc.api.ExecutionProperties;
@@ -282,7 +276,11 @@
      */
     public void setAsciiStream (int parameterIndex, java.io.InputStream in, int length) throws SQLException {
         //create a clob from the ascii stream
-    	setObject(parameterIndex, new ClobImpl(in, Charset.forName("ASCII"), length)); //$NON-NLS-1$
+    	try {
+			setObject(parameterIndex, new SerialClob(ObjectConverterUtil.convertToCharArray(in, length, "ASCII"))); //$NON-NLS-1$
+		} catch (IOException e) {
+			throw MMSQLException.create(e);
+		} 
     }
 
     /**
@@ -305,7 +303,11 @@
      */
     public void setBinaryStream(int parameterIndex, java.io.InputStream in, int length) throws SQLException {
     	//create a blob from the ascii stream
-    	setObject(parameterIndex, new BlobImpl(in, length));
+    	try {
+			setObject(parameterIndex, new SerialBlob(ObjectConverterUtil.convertToByteArray(in, length)));
+		} catch (IOException e) {
+			throw MMSQLException.create(e);
+		}
     }
 
     /**
@@ -347,18 +349,16 @@
      */
     public void setBytes(int parameterIndex, byte bytes[]) throws SQLException {
     	//create a blob from the ascii stream
-    	setObject(parameterIndex, new BlobImpl(bytes));
+    	setObject(parameterIndex, new SerialBlob(bytes));
     }
 
-    /**
-     * <p>Sets the parameter in position parameterIndex to a Reader stream object.
-     * @param parameterIndex of the parameter whose value is to be set
-     * @param Reader object to which the parameter value is to be set.
-     * @param length indicating number of charachters to be read from the stream
-     */
     public void setCharacterStream (int parameterIndex, java.io.Reader reader, int length) throws SQLException {
     	//create a clob from the ascii stream
-    	setObject(parameterIndex, new ClobImpl(reader, length));
+    	try {
+			setObject(parameterIndex, new SerialClob(ObjectConverterUtil.convertToCharArray(reader, length)));
+		} catch (IOException e) {
+			throw MMSQLException.create(e);
+		}
     }
 
     /**

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestDataTypeTransformer.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestDataTypeTransformer.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestDataTypeTransformer.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -25,15 +25,15 @@
 import java.sql.Clob;
 import java.sql.SQLException;
 
+import javax.sql.rowset.serial.SerialClob;
+
 import junit.framework.TestCase;
 
-import com.metamatrix.common.types.ClobImpl;
-
 public class TestDataTypeTransformer extends TestCase {
 	
 	public void testClobToStringConversion() throws Exception {
-		Clob clob = new ClobImpl("foo".toCharArray()); //$NON-NLS-1$
-		String value = DataTypeTransformer.getString(clob); //$NON-NLS-1$
+		Clob clob = new SerialClob("foo".toCharArray()); //$NON-NLS-1$
+		String value = DataTypeTransformer.getString(clob);
 		assertEquals("foo", value); //$NON-NLS-1$
 	}
 	

Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/BlobImpl.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/BlobImpl.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/BlobImpl.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -1,299 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.sql.Blob;
-import java.sql.SQLException;
-
-import com.metamatrix.common.util.SqlUtil;
-import com.metamatrix.core.CorePlugin;
-
-/**
- * This object holds a chunk of binary data and implements the JDBC Blob interface.
- * This object presents a streaming interface but actually encapsulates the entire
- * blob object.  Connectors can construct this object when dealing with large
- * objects.
- */
-public class BlobImpl implements Blob, Serializable {
-
-    //if no default is set, this default size is used by the connector.
-    public static final int DEFAULT_MAX_SIZE = 5000000;
-    private byte[] data;
-
-    /**
-     * Creates a MMBlob object by calling <code>getBytes</code> on the 
-     * <code>Blob</code> argument.
-     * @param blob the Blob object to get the data from.
-     */
-    public BlobImpl(Blob blob) throws SQLException {
-        int length = (int) blob.length();
-        data = blob.getBytes(1, length);
-    }
-
-    /**
-     * Creates a MMBlob object by copying the data in <code>originalData</code>
-     * @param originalData the array of bytes to copy into this MMBlob object.
-     */
-    public BlobImpl(byte[] originalData) {
-        data = new byte[originalData.length];
-        int originalDataStartPosition = 0;
-        int dataStartPosition = 0;
-        int bytesToCopy = originalData.length;
-        System.arraycopy(originalData, originalDataStartPosition, data, dataStartPosition, bytesToCopy);
-    }
-
-    public BlobImpl(InputStream in, int length) throws SQLException{
-    	data = new byte[length];
-    	try {
-			in.read(data, 0, length);
-		} catch (IOException e) {
-			throw new SQLException(e.getMessage());
-		}
-    }
-    
-    /**
-     * Retrieves the <code>BLOB</code> designated by this
-     * <code>Blob</code> instance as a stream.
-     * @return a stream containing the <code>BLOB</code> data
-     * @exception SQLException if there is an error accessing the
-     * <code>BLOB</code>
-     */
-    public InputStream getBinaryStream() throws SQLException {
-        return new ByteArrayInputStream(data);
-    }
-
-    /**
-     * Returns as an array of bytes, part or all of the <code>BLOB</code>
-     * value that this <code>Blob</code> object designates.  The byte
-     * array contains up to <code>length</code> consecutive bytes
-     * starting at position <code>pos</code>.
-     * @param pos the ordinal position of the first byte in the 
-     * <code>BLOB</code> value to be extracted; the first byte is at
-     * position 1
-     * @param length the number of consecutive bytes to be copied
-     * @return a byte array containing up to <code>length</code> 
-     * consecutive bytes from the <code>BLOB</code> value designated
-     * by this <code>Blob</code> object, starting with the
-     * byte at position <code>pos</code>
-     * @exception SQLException if there is an error accessing the
-     * <code>BLOB</code>
-     */
-    public byte[] getBytes(long pos, int length) throws SQLException {
-        if (pos < 1) {
-            throw new SQLException(CorePlugin.Util.getString("BlobImpl.Invalid_byte_position",  new Long(pos))); //$NON-NLS-1$
-        }
-
-        if (pos > data.length) {
-            return null;
-        }
-
-        if (length < 0) {
-            throw new SQLException(CorePlugin.Util.getString("BlobImpl.Invalid_bytes_length",  new Long(length))); //$NON-NLS-1$
-        }
-
-        if (length > data.length) {
-            length = data.length;
-        }
-
-        byte[] dataCopy = new byte[length];
-        int startingDataPosition = (int) pos - 1; //pos is the ordinal index (starts at 1) so we need pos - 1
-        int startingCopyPosition = 0;
-        System.arraycopy(data, startingDataPosition, dataCopy, startingCopyPosition, length);
-        return dataCopy;
-    }
-
-    /**
-     * Returns the number of bytes in the <code>BLOB</code> value
-     * designated by this <code>Blob</code> object.
-     * @return length of the <code>BLOB</code> in bytes
-     * @exception SQLException if there is an error accessing the
-     * length of the <code>BLOB</code>
-     */
-    public long length() throws SQLException {
-        return data.length;
-    }
-
-    /** 
-     * Determines the byte position in the <code>BLOB</code> value
-     * designated by this <code>Blob</code> object at which 
-     * <code>pattern</code> begins.  The search begins at position
-     * <code>start</code>.
-     * @param pattern the <code>Blob</code> object designating
-     * the <code>BLOB</code> value for which to search
-     * @param start the position in the <code>BLOB</code> value
-     *        at which to begin searching; the first position is 1
-     * @return the position at which the pattern begins, else -1
-     * @exception SQLException if there is an error accessing the
-     * <code>BLOB</code>
-     */
-    public long position(Blob pattern, long start) throws SQLException {
-        if (pattern == null || start > data.length) {
-            return -1;
-        }
-        int length = (int) pattern.length();
-        byte[] patternBytes = pattern.getBytes(1, length);
-        return position(patternBytes, start);
-    }
-
-    /** 
-     * Determines the byte position at which the specified byte 
-     * <code>pattern</code> begins within the <code>BLOB</code>
-     * value that this <code>Blob</code> object represents.  The
-     * search for <code>pattern</code> begins at position
-     * <code>start</code>.  
-     * @param pattern the byte array for which to search
-     * @param start the position at which to begin searching; the
-     *        first position is 1
-     * @return the position at which the pattern appears, else -1
-     * @exception SQLException if there is an error accessing the 
-     * <code>BLOB</code>
-     */
-    public long position(byte[] pattern, long start) throws SQLException {
-        if (start < 1) {
-            throw new SQLException(CorePlugin.Util.getString("BlobImpl.Invalid_start_position",  new Long(start))); //$NON-NLS-1$
-        }
-        if (pattern == null || start > data.length) {
-            return -1;
-        }
-        String patternString = new String(pattern);
-        String byteString = new String(data);
-        start--;
-        int position = byteString.indexOf(patternString, (int) start);
-        if (position != -1)
-            position++;
-        return position;
-    }
-
-    /**
-     * Compares two MMBlob objects for equality.
-     * @return True if equal
-     * @see java.lang.Object#equals(Object)
-     */
-    public boolean equals(Object obj) {
-        try {
-            if (obj == null || data == null) {
-                return false;
-            }
-
-            if (obj == this) {
-                return true;
-            }
-
-            if (!(obj instanceof BlobImpl)) {
-                return false;
-            }
-
-            BlobImpl blob = (BlobImpl) obj;
-
-            if (blob.length() != length()) {
-                return false;
-            }
-
-            byte[] bytes = blob.getBytes(1, (int) blob.length());
-
-            for (int i = 0; i < bytes.length; i++) {
-                if (bytes[i] != data[i]) {
-                    return false;
-                }
-            }
-        } catch (SQLException e) {
-            return false;
-        }
-        return true;
-    }
-
-    /** 
-     * Returns a String that is a comma delimited list of up to the first 5 and 
-     * last 5 bytes of the Blob in Hexadecimal.
-     * @return the String object convenient for displaying this Blob object
-     */
-    public String toString() {
-        String pre = "{"; //$NON-NLS-1$
-        String post = ""; //$NON-NLS-1$
-
-        int lastByte = data.length - 1;
-        int frontTruncate = 5;
-        int endTruncate = lastByte - 5;
-
-        if (lastByte < 10) {
-            frontTruncate = lastByte;
-            endTruncate = lastByte;
-        }
-
-        for (int i = 0; i < frontTruncate; i++) {
-            pre += Integer.toString(data[i], 16) + ","; //$NON-NLS-1$
-        }
-
-        for (int i = endTruncate; i < lastByte; i++) {
-            post += "," + Integer.toString(data[i], 16); //$NON-NLS-1$
-        }
-
-        post += "}"; //$NON-NLS-1$
-
-        return "Length:" + data.length + ":" + pre + "..." + post; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-	/**
-	 * @see java.sql.Blob#setBytes(long, byte[])
-	 */
-	public int setBytes(long pos, byte[] bytes) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	/**
-	 * @see java.sql.Blob#setBytes(long, byte[], int, int)
-	 */
-	public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	/**
-	 * @see java.sql.Blob#setBinaryStream(long)
-	 */
-	public OutputStream setBinaryStream(long pos) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	/**
-	 * @see java.sql.Blob#truncate(long)
-	 */
-	public void truncate(long len) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	public void free() throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	public InputStream getBinaryStream(long arg0, long arg1)
-			throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-}
-
-

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/BlobType.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -29,7 +29,11 @@
 import java.sql.Blob;
 import java.sql.SQLException;
 
+import javax.sql.rowset.serial.SerialBlob;
+import javax.sql.rowset.serial.SerialException;
+
 import com.metamatrix.core.CorePlugin;
+import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.core.util.ArgCheck;
 
 /**
@@ -240,4 +244,16 @@
 		return this.srcBlob.getBinaryStream(pos, length);
 	}
 	//## JDBC4.0-end ##
+	
+	public static SerialBlob createBlob(byte[] bytes) {
+		if (bytes == null) {
+			return null;
+		}
+		try {
+			return new SerialBlob(bytes);
+		} catch (SQLException e) {
+			throw new MetaMatrixRuntimeException(e);
+		}
+	}
+	
 }

Deleted: trunk/common-core/src/main/java/com/metamatrix/common/types/ClobImpl.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/ClobImpl.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/ClobImpl.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -1,341 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types;
-
-import java.io.ByteArrayInputStream;
-import java.io.CharArrayReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Serializable;
-import java.io.Writer;
-import java.nio.charset.Charset;
-import java.sql.Clob;
-import java.sql.SQLException;
-import java.util.Arrays;
-/*## JDBC3.0-JDK1.5-begin ##
-import java.io.UnsupportedEncodingException;
-## JDBC3.0-JDK1.5-end ##*/
-
-
-import com.metamatrix.common.util.SqlUtil;
-import com.metamatrix.core.CorePlugin;
-
-/**
- * This object holds a chunk of character data and implements the JDBC Clob interface. 
- * This object presents a streaming interface but actually encapsulates the entire clob 
- * object.  Connectors can construct this object when dealing with large objects.
- */
-public class ClobImpl implements Clob, Serializable {
-
-    public static final int DEFAULT_MAX_SIZE = 5000000;
-
-    private char[] data;
-
-    /**
-     * Creates a MMClob object by using the CharacterStream of the 
-     * <code>Clob</code> argument.
-     * @param clob the Clob object to get the characters from.
-     */
-    public ClobImpl(Clob clob) throws SQLException {
-        try {
-            int length = (int) clob.length();
-            data = new char[length];
-            Reader reader = clob.getCharacterStream();
-            int charsRead = 0;
-            int start = 0;
-            int bytesToRead = length;
-            while ((charsRead = reader.read(data, start, bytesToRead)) != -1 && bytesToRead != 0) {
-                start += charsRead;
-                bytesToRead -= charsRead;
-            }
-
-        } catch (IOException ioe) {
-            throw new SQLException(CorePlugin.Util.getString("ClobImpl.Failed_copy_clob",  ioe.getMessage())); //$NON-NLS-1$
-        }
-    }
-
-    /**
-     * Creates a MMClob object by copying the chars in <code>originalData</code>
-     * @param originalData the array of chars to copy into this MMClob object.
-     */
-    public ClobImpl(char[] originalData) {
-        data = new char[originalData.length];
-        int originalDataStartPosition = 0;
-        int dataStartPosition = 0;
-        int charsToCopy = originalData.length;
-        System.arraycopy(originalData, originalDataStartPosition, data, dataStartPosition, charsToCopy);
-    }
-
-    public ClobImpl(InputStream in, Charset charSet, int length) throws SQLException{
-    	data = new char[length];
-    	try {
-			new InputStreamReader(in, charSet).read(data, 0, length);
-		} catch (IOException e) {
-			throw new SQLException(e.getMessage());
-		}
-    }
-    
-    public ClobImpl(Reader reader, int length) throws SQLException{
-    	data = new char[length];
-    	try {
-    		reader.read(data, 0, length);
-		} catch (IOException e) {
-			throw new SQLException(e.getMessage());
-		}
-    }
-    
-    /**
-     * Gets the <code>CLOB</code> value designated by this <code>Clob</code>
-     * object as a stream of Ascii bytes.
-     * @return an ascii stream containing the <code>CLOB</code> data
-     * @exception SQLException if there is an error accessing the 
-     * <code>CLOB</code> value
-     */
-    public InputStream getAsciiStream() throws SQLException {
-    	//## JDBC4.0-begin ##
-        byte[] bytes = new String(data).getBytes(Charset.forName("US-ASCII")); //$NON-NLS-1$
-      //## JDBC4.0-end ##
-		/*## JDBC3.0-JDK1.5-begin ##
-		byte[] bytes;
-		try {
-			bytes = new String(data).getBytes("US-ASCII"); //$NON-NLS-1$
-		} catch (UnsupportedEncodingException e) {
-			throw new SQLException(e.getMessage());
-		} 
-		## JDBC3.0-JDK1.5-end ##*/
-        return new ByteArrayInputStream(bytes);
-    }
-
-    /**
-     * Gets the <code>CLOB</code> value designated by this <code>Clob</code>
-     * object as a Unicode stream.
-     * @return a Unicode stream containing the <code>CLOB</code> data
-     * @exception SQLException if there is an error accessing the 
-     * <code>CLOB</code> value
-     */
-    public Reader getCharacterStream() throws SQLException {
-        return new CharArrayReader(data);
-    }
-
-    /**
-     * Returns a copy of the specified substring 
-     * in the <code>CLOB</code> value
-     * designated by this <code>Clob</code> object.
-     * The substring begins at position
-     * <code>pos</code> and has up to <code>length</code> consecutive
-     * characters.
-     * @param pos the first character of the substring to be extracted.
-     *            The first character is at position 1.
-     * @param length the number of consecutive characters to be copied
-     * @return a <code>String</code> that is the specified substring in
-     *         the <code>CLOB</code> value designated by this <code>Clob</code> object
-     * @exception SQLException if there is an error accessing the
-     * <code>CLOB</code> 
-     */
-    public String getSubString(long pos, int length) throws SQLException {
-
-        if (pos < 1) {
-            throw new SQLException(CorePlugin.Util.getString("ClobImpl.Invalid_substring_position",  new Long(pos))); //$NON-NLS-1$
-        }
-
-        if (pos > data.length) {
-            return null;
-        }
-
-        if (length < 0) {
-            throw new SQLException(CorePlugin.Util.getString("ClobImpl.Invalid_substring_length",  new Long(length))); //$NON-NLS-1$
-        }
-
-        if (length > data.length) {
-            length = data.length;
-        }
-
-        pos--; //the API specifies that the first char is at pos = 1
-        return new String(data, (int) pos, length);
-    }
-
-    /**
-     * Returns the number of characters 
-     * in the <code>CLOB</code> value
-     * designated by this <code>Clob</code> object.
-     * @return length of the <code>CLOB</code> in characters
-     * @exception SQLException if there is an error accessing the
-     * length of the <code>CLOB</code>
-     */
-    public long length() throws SQLException {
-        return data.length;
-    }
-
-    /** 
-     * Determines the character position at which the specified  
-     * <code>Clob</code> object <code>searchstr</code> appears in this 
-     * <code>Clob</code> object.  The search begins at position 
-     * <code>start</code>.
-     * @param searchstr the <code>Clob</code> object for which to search
-     * @param start the position at which to begin searching; the first
-     *              position is 1
-     * @return the position at which the <code>Clob</code> object appears, 
-     * else -1; the first position is 1
-     * @exception SQLException if there is an error accessing the 
-     * <code>CLOB</code> value
-     */
-    public long position(Clob searchstr, long start) throws SQLException {
-
-        if (searchstr == null || start > data.length) {
-            return -1;
-        }
-        int length = (int) searchstr.length();
-        String searchString = searchstr.getSubString(1, length);
-        return position(searchString, start);
-    }
-
-    /** 
-    * Determines the character position at which the specified substring 
-    * <code>searchstr</code> appears in the SQL <code>CLOB</code> value
-    * represented by this <code>Clob</code> object.  The search 
-    * begins at position <code>start</code>.
-    * @param searchstr the substring for which to search 
-    * @param start the position at which to begin searching; the first position
-    *              is 1
-    * @return the position at which the substring appears, else -1; the first
-    *         position is 1
-    * @exception SQLException if there is an error accessing the       
-    * <code>CLOB</code> value
-    */
-    public long position(String searchstr, long start) throws SQLException {
-        if (start < 1) {
-            throw new SQLException(CorePlugin.Util.getString("ClobImpl.Invalid_start_position",  new Long(start))); //$NON-NLS-1$
-        }
-        if (searchstr == null || start > data.length) {
-            return -1;
-        }
-        String str = new String(data);
-        start--;
-        int position = str.indexOf(searchstr, (int) start);
-        if (position != -1)
-            position++;
-        return position;
-    }
-
-    /**
-     * Compares two MMClob objects for equality.
-     * @return True if equal
-     * @see java.lang.Object#equals(Object)
-     */
-    public boolean equals(Object obj) {
-        if (obj == null || data == null) {
-            return false;
-        }
-
-        if (obj == this) {
-            return true;
-        }
-
-        if (!(obj instanceof ClobImpl)) {
-            return false;
-        }
-
-        ClobImpl clob = (ClobImpl) obj;
-        
-        return Arrays.equals(data, clob.data);
-    }
-
-    /** 
-     * Returns a String that is a coma delimited list of up to
-     * the first 5 and last 5 chars of the Clob.
-     * @return the String object convenient for displaying this Clob object
-     */
-    public String toString() {
-
-        String pre = "{"; //$NON-NLS-1$
-        String post = ""; //$NON-NLS-1$
-
-        int lastByte = data.length - 1;
-        int frontTruncate = 5;
-        int endTruncate = lastByte - 5;
-
-        if (lastByte < 10) {
-            frontTruncate = lastByte;
-            endTruncate = lastByte;
-        }
-
-        for (int i = 0; i < frontTruncate; i++) {
-            pre += data[i] + ","; //$NON-NLS-1$
-        }
-
-        for (int i = endTruncate; i < lastByte; i++) {
-            post += "," + data[i]; //$NON-NLS-1$
-        }
-
-        post += "}"; //$NON-NLS-1$
-
-        return "Length:" + data.length + ":" + pre + "..." + post; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-    }
-
-	/**
-	 * @see java.sql.Clob#setString(long, java.lang.String)
-	 */
-	public int setString(long pos, String str) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	/**
-	 * @see java.sql.Clob#setString(long, java.lang.String, int, int)
-	 */
-	public int setString(long pos, String str, int offset, int len) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	/**
-	 * @see java.sql.Clob#setAsciiStream(long)
-	 */
-	public OutputStream setAsciiStream(long pos) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	/**
-	 * @see java.sql.Clob#setCharacterStream(long)
-	 */
-	public Writer setCharacterStream(long pos) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	/**
-	 * @see java.sql.Clob#truncate(long)
-	 */
-	public void truncate(long len) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	public void free() throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-	public Reader getCharacterStream(long arg0, long arg1) throws SQLException {
-		throw SqlUtil.createFeatureNotSupportedException();
-	}
-
-}

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/ClobType.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/ClobType.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/ClobType.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -31,6 +31,10 @@
 import java.sql.Clob;
 import java.sql.SQLException;
 
+import javax.sql.rowset.serial.SerialBlob;
+import javax.sql.rowset.serial.SerialClob;
+import javax.sql.rowset.serial.SerialException;
+
 import com.metamatrix.core.CorePlugin;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 
@@ -304,4 +308,12 @@
 		return this.srcClob.getCharacterStream(pos, length);
 	}
 	//## JDBC4.0-end ##
+	
+	public static SerialClob createClob(char[] chars) {
+		try {
+			return new SerialClob(chars);
+		} catch (SQLException e) {
+			throw new MetaMatrixRuntimeException(e);
+		}
+	}
 }

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/DataTypeManager.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -993,7 +993,7 @@
 			@Override
 			//## JDBC4.0-end ##
 			public ClobType transform(char[] value) {
-				return new ClobType(new ClobImpl(value));
+				return new ClobType(ClobType.createClob(value));
 			}
 		});
 		sourceConverters.put(Blob.class, new SourceTransform<Blob, BlobType>() {
@@ -1009,7 +1009,7 @@
 			@Override
 			//## JDBC4.0-end ##
 			public BlobType transform(byte[] value) {
-				return new BlobType(new BlobImpl(value));
+				return new BlobType(BlobType.createBlob(value));
 			}
 		});
 		sourceConverters.put(SQLXML.class, new SourceTransform<SQLXML, XMLType>() {

Modified: trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToClobTransform.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToClobTransform.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/main/java/com/metamatrix/common/types/basic/StringToClobTransform.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -23,7 +23,6 @@
 package com.metamatrix.common.types.basic;
 
 import com.metamatrix.common.types.AbstractTransform;
-import com.metamatrix.common.types.ClobImpl;
 import com.metamatrix.common.types.ClobType;
 import com.metamatrix.common.types.TransformationException;
 
@@ -43,7 +42,7 @@
         }
         
         String contents = (String)value;                
-		return new ClobType(new ClobImpl(contents.toCharArray()));
+		return new ClobType(ClobType.createClob(contents.toCharArray()));
 	}
 
 	/**

Modified: trunk/common-core/src/main/java/com/metamatrix/core/util/FileUtil.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/FileUtil.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/FileUtil.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -118,10 +118,12 @@
             reader = new FileReader(this.file);
             result = read(reader);
         } finally {
-            try {
-                reader.close();
-            } catch (Exception e) {                
-            }
+        	if (reader != null) {
+	            try {
+	                reader.close();
+	            } catch (Exception e) {                
+	            }
+        	}
         }
         
         return result;
@@ -140,10 +142,12 @@
         } catch (IOException e) {
             throw new MetaMatrixRuntimeException(e);
         } finally {
-            try {
-                bufferedReader.close();
-            } catch (Exception e) {                
-            }
+        	if (bufferedReader != null) {
+	            try {
+	                bufferedReader.close();
+	            } catch (Exception e) {                
+	            }
+        	}
         }
         return writer.toString();
     }

Modified: trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/ObjectConverterUtil.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -33,6 +33,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.Reader;
 import java.sql.SQLException;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
@@ -375,6 +376,18 @@
             }
         }
     }
+    
+    public static String convertToString(Reader reader) throws IOException {
+    	return new String(convertToCharArray(reader, Integer.MAX_VALUE));
+    }
 
+    public static char[] convertToCharArray(Reader reader, int length) throws IOException {
+        StringBuilder sb = new StringBuilder();        
+        int chr = -1;
+        for (int i = 0; i < length && (chr = reader.read()) != -1; i ++) {
+            sb.append((char)chr);
+        }
+        return sb.toString().toCharArray();
+    }
 
 } 

Deleted: trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobImpl.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobImpl.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobImpl.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.sql.Blob;
-
-import com.metamatrix.common.types.BlobImpl;
-
-import junit.framework.TestCase;
-
-public class TestBlobImpl extends TestCase{
-	private Blob blob;
-	
-    public TestBlobImpl(String name) {
-        super(name);
-    }
-    
-    public void setUp() throws Exception{
-    	ByteArrayInputStream in = new ByteArrayInputStream("test blob".getBytes()); //$NON-NLS-1$
-    	blob = new BlobImpl(in, 9);
-    }
-    
-    public void testGetBinaryStream() throws Exception{
-    	InputStream in = blob.getBinaryStream();
-    	BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-    	assertEquals("test blob", reader.readLine()); //$NON-NLS-1$
-    	assertNull(reader.readLine());
-    }
-    
-    public void testGetBytes() throws Exception{
-    	byte[] bytes = blob.getBytes(2, 5);
-    	assertEquals("est b", new String(bytes)); //$NON-NLS-1$
-    }
-    
-    public void testLength() throws Exception{
-    	assertEquals(9, blob.length()); 
-    }
-    
-    public void testPosition() throws Exception{
-    	assertEquals(3, blob.position("st".getBytes(), 2)); //$NON-NLS-1$
-    }
-    
-    public void testEquals() throws Exception{
-    	assertEquals(blob, new BlobImpl(new ByteArrayInputStream("test blob".getBytes()), 9)); //$NON-NLS-1$
-    }
-}

Modified: trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobValue.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobValue.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/TestBlobValue.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -28,6 +28,8 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import javax.sql.rowset.serial.SerialBlob;
+
 import com.metamatrix.core.util.UnitTestUtil;
 
 import junit.framework.TestCase;
@@ -37,7 +39,7 @@
 
     public void testBlobValue() throws Exception {
         String testString = "this is test blob"; //$NON-NLS-1$
-        BlobImpl blob = new BlobImpl(testString.getBytes()); 
+        SerialBlob blob = new SerialBlob(testString.getBytes()); 
         
         BlobType bv = new BlobType(blob);
         assertEquals(testString, new String(bv.getBytes(1L, (int)bv.length())));
@@ -46,7 +48,7 @@
     
     public void testClobValuePersistence() throws Exception {
         String testString = "this is test clob"; //$NON-NLS-1$
-        BlobImpl blob = new BlobImpl(testString.getBytes());
+        SerialBlob blob = new SerialBlob(testString.getBytes());
         
         String key = "keytodata"; //$NON-NLS-1$
         BlobType bv = new BlobType(blob);
@@ -76,10 +78,4 @@
         saved.delete();
     }
     
-    public void testEquals() {
-    	BlobType blob = new BlobType(new BlobImpl(new byte[3]));
-    	BlobType blob1 = new BlobType(new BlobImpl(new byte[3]));
-    	assertTrue(blob.equals(blob1));
-    }
-    
 }

Deleted: trunk/common-core/src/test/java/com/metamatrix/common/types/TestClobImpl.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/TestClobImpl.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/TestClobImpl.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.types;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.sql.Clob;
-
-import com.metamatrix.common.types.ClobImpl;
-
-import junit.framework.TestCase;
-
-public class TestClobImpl extends TestCase{
-	private Clob clob;
-	
-    public TestClobImpl(String name) {
-        super(name);
-    }
-    
-    public void setUp() throws Exception{
-    	Reader reader = new StringReader("test clob"); //$NON-NLS-1$
-    	clob = new ClobImpl(reader, 9);
-    }
-    
-    public void testGetAsciiStream() throws Exception{
-    	InputStream in = clob.getAsciiStream();
-    	BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-    	assertEquals("test clob", reader.readLine()); //$NON-NLS-1$
-    	assertNull(reader.readLine());
-    }
-    
-    public void testGetCharacterStream() throws Exception{
-    	BufferedReader reader = new BufferedReader(clob.getCharacterStream());
-    	assertEquals("test clob", reader.readLine()); //$NON-NLS-1$
-    	assertNull(reader.readLine());
-    }
-    
-    public void testGetSubString() throws Exception{
-    	assertEquals("est", clob.getSubString(2,3)); //$NON-NLS-1$
-    }
-    
-    public void testLength() throws Exception{
-    	assertEquals(9, clob.length()); 
-    }
-    
-    public void testPosition() throws Exception{
-    	assertEquals(3, clob.position("st", 2)); //$NON-NLS-1$
-    }
-    
-    public void testEquals() throws Exception{
-    	assertEquals(clob, new ClobImpl(new StringReader("test clob"), 9)); //$NON-NLS-1$
-    }
-}

Modified: trunk/common-core/src/test/java/com/metamatrix/common/types/TestClobValue.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/TestClobValue.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/TestClobValue.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -28,6 +28,8 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import javax.sql.rowset.serial.SerialClob;
+
 import com.metamatrix.core.util.UnitTestUtil;
 
 import junit.framework.TestCase;
@@ -37,7 +39,7 @@
 
     public void testClobValue() throws Exception {
         String testString = "this is test clob"; //$NON-NLS-1$
-        ClobImpl clob = new ClobImpl(testString.toCharArray()); 
+        SerialClob clob = new SerialClob(testString.toCharArray()); 
         
         ClobType cv = new ClobType(clob);
         assertEquals(testString, cv.getSubString(1L, (int)cv.length()));
@@ -46,7 +48,7 @@
     
     public void testClobValuePersistence() throws Exception {
         String testString = "this is test clob"; //$NON-NLS-1$
-        ClobImpl clob = new ClobImpl(testString.toCharArray());
+        SerialClob clob = new SerialClob(testString.toCharArray());
         
         String key = "keytodata"; //$NON-NLS-1$
         ClobType cv = new ClobType(clob);

Modified: trunk/common-core/src/test/java/com/metamatrix/common/types/TestDataTypeManager.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/TestDataTypeManager.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/TestDataTypeManager.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -26,6 +26,8 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import javax.sql.rowset.serial.SerialBlob;
+
 import junit.framework.TestCase;
 
 public class TestDataTypeManager extends TestCase {
@@ -186,10 +188,10 @@
         assertEquals(MMJDBCSQLTypeInfo.getSQLTypeFromRuntimeType(DataTypeManager.DefaultDataClasses.TIMESTAMP), Types.TIMESTAMP);
     }
     
-    public void testRuntimeTypeConversion() {
+    public void testRuntimeTypeConversion() throws Exception {
     	assertNull(DataTypeManager.convertToRuntimeType(null));
     	
-    	assertTrue(DataTypeManager.convertToRuntimeType(new BlobImpl(new byte[0])) instanceof BlobType);
+    	assertTrue(DataTypeManager.convertToRuntimeType(new SerialBlob(new byte[0])) instanceof BlobType);
     
     	//unknown type should return as same
     	Object foo = new Object();

Modified: trunk/common-core/src/test/java/com/metamatrix/common/types/TestSQLXMLImpl.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/TestSQLXMLImpl.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/TestSQLXMLImpl.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -23,7 +23,6 @@
 package com.metamatrix.common.types;
 
 import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
@@ -36,6 +35,8 @@
 
 import junit.framework.TestCase;
 
+import com.metamatrix.core.util.ObjectConverterUtil;
+
 /**
  * Basically we want to make sure that nobody has changed the fundamental contract
  * of translator
@@ -83,7 +84,7 @@
 
     public void testGetBinaryStream() throws Exception {
         SQLXMLImpl xml = new SQLXMLImpl(translator);
-        assertEquals(testStr, getContents(xml.getBinaryStream()));
+        assertEquals(testStr, ObjectConverterUtil.convertToString(xml.getBinaryStream()));
 
     }
 
@@ -128,17 +129,6 @@
         }
         reader.close();       
         return sb.toString();
-    }
+    } 
     
-    private String getContents(InputStream reader) throws IOException {
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        int chr = reader.read();
-        while(chr != -1) {
-            out.write((byte)chr);
-            chr = reader.read();
-        }
-        reader.close();       
-        return new String(out.toByteArray());
-    }    
-    
 }

Modified: trunk/common-core/src/test/java/com/metamatrix/common/types/TestXMLStreamSourceTranslator.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/TestXMLStreamSourceTranslator.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/TestXMLStreamSourceTranslator.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -33,6 +33,8 @@
 
 import javax.xml.transform.stream.StreamSource;
 
+import com.metamatrix.core.util.ObjectConverterUtil;
+
 import junit.framework.TestCase;
 
 
@@ -87,25 +89,13 @@
     public void testGetReader() throws Exception {        
         XMLStreamSourceTranslator translator = new XMLStreamSourceTranslator(new StreamSource(new StringReader(sourceXML)),  new Properties());
         Reader reader = translator.getReader();
-        StringBuffer sb = readContents(reader);       
-        assertEquals(sourceXML, sb.toString());
+        assertEquals(sourceXML, ObjectConverterUtil.convertToString(reader));
     }
 
-    private StringBuffer readContents(Reader reader) throws IOException {
-        StringBuffer sb = new StringBuffer();        
-        int chr = reader.read();
-        while(chr != -1) {
-            sb.append((char)chr);
-            chr = reader.read();
-        }
-        return sb;
-    }
-
     public void testCharInput() throws Exception {        
         XMLStreamSourceTranslator translator = new XMLStreamSourceTranslator(sourceXML.toCharArray(),  new Properties());
         Reader reader = translator.getReader();
-        StringBuffer sb = readContents(reader);       
-        assertEquals(sourceXML, sb.toString());
+        assertEquals(sourceXML, ObjectConverterUtil.convertToString(reader));
     }
     
     public void testXMLReaderFactory() throws Exception {        
@@ -115,8 +105,7 @@
             }            
         }, new Properties());
         Reader reader = translator.getReader();
-        StringBuffer sb = readContents(reader);       
-        assertEquals(sourceXML, sb.toString());
+        assertEquals(sourceXML, ObjectConverterUtil.convertToString(reader));
     }    
     
     /*
@@ -156,8 +145,7 @@
         assertTrue(translator.getSource() instanceof StreamSource);
         StreamSource s = (StreamSource)translator.getSource();
         Reader reader = s.getReader();
-        StringBuffer sb = readContents(reader);  
-        assertEquals(sourceXML, sb.toString());
+        assertEquals(sourceXML, ObjectConverterUtil.convertToString(reader));
     }
 
     /*

Modified: trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/common-core/src/test/java/com/metamatrix/common/types/basic/TestTransforms.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -30,7 +30,6 @@
 
 import junit.framework.TestCase;
 
-import com.metamatrix.common.types.ClobImpl;
 import com.metamatrix.common.types.ClobType;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.common.types.SQLXMLImpl;
@@ -134,7 +133,7 @@
         /*timestamp-13*/{new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis()), new Timestamp(System.currentTimeMillis())},
         /*object-14*/  {null, null, null},  
         /*blob-15*/    {null, null, null},
-        /*clob-16*/    {new ClobType(new ClobImpl("ClobData".toCharArray())), new ClobType(new ClobImpl("0".toCharArray())), new ClobType(new ClobImpl("123".toCharArray()))}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        /*clob-16*/    {new ClobType(ClobType.createClob("ClobData".toCharArray())), new ClobType(ClobType.createClob("0".toCharArray())), new ClobType(ClobType.createClob("123".toCharArray()))}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
         /*xml-17*/     {new XMLType(new SQLXMLImpl("<foo>bar</foo>")), new XMLType(new SQLXMLImpl("<foo>bar</foo>")), new XMLType(new SQLXMLImpl("<foo>bar</foo>"))}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }; 
     

Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java	2009-06-09 18:00:27 UTC (rev 1031)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java	2009-06-09 18:11:52 UTC (rev 1032)
@@ -22,6 +22,7 @@
 
 package com.metamatrix.connector.metadata.internal;
 
+import java.io.IOException;
 import java.nio.charset.Charset;
 import java.sql.SQLException;
 import java.util.ArrayList;
@@ -31,14 +32,16 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.sql.rowset.serial.SerialClob;
+
 import org.teiid.connector.api.ConnectorException;
 
-import com.metamatrix.common.types.ClobImpl;
 import com.metamatrix.common.types.ClobType;
 import com.metamatrix.common.vdb.api.VDBFile;
 import com.metamatrix.connector.metadata.MetadataConnectorConstants;
 import com.metamatrix.connector.metadata.ResultsIterator;
 import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.util.ObjectConverterUtil;
 
 
 /**
@@ -167,10 +170,12 @@
                 if (value instanceof VDBFile) {
                     try {
                     	VDBFile record = (VDBFile)value;
-                        value = new ClobImpl(record.getContent(), Charset.defaultCharset(), (int)record.getFileLength());
+                        value = new SerialClob(ObjectConverterUtil.convertToCharArray(record.getContent(), (int)record.getFileLength(), null));
                     } catch (SQLException e) {
                         throw new RuntimeException(e);
-                    }
+                    } catch (IOException e) {
+                    	throw new RuntimeException(e);
+					}
                 }
             }
             newRow.add(value);




More information about the teiid-commits mailing list