com.metamatrix.common.types
Class ClobImpl

java.lang.Object
  extended by com.metamatrix.common.types.ClobImpl
All Implemented Interfaces:
java.io.Serializable, java.sql.Clob

public class ClobImpl
extends java.lang.Object
implements java.sql.Clob, java.io.Serializable

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.

See Also:
Serialized Form

Field Summary
static int DEFAULT_MAX_SIZE
           
 
Constructor Summary
ClobImpl(char[] originalData)
          Creates a MMClob object by copying the chars in originalData
ClobImpl(java.sql.Clob clob)
          Creates a MMClob object by using the CharacterStream of the Clob argument.
ClobImpl(java.io.InputStream in, java.nio.charset.Charset charSet, int length)
           
ClobImpl(java.io.Reader reader, int length)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares two MMClob objects for equality.
 void free()
           
 java.io.InputStream getAsciiStream()
          Gets the CLOB value designated by this Clob object as a stream of Ascii bytes.
 java.io.Reader getCharacterStream()
          Gets the CLOB value designated by this Clob object as a Unicode stream.
 java.io.Reader getCharacterStream(long arg0, long arg1)
           
 java.lang.String getSubString(long pos, int length)
          Returns a copy of the specified substring in the CLOB value designated by this Clob object.
 long length()
          Returns the number of characters in the CLOB value designated by this Clob object.
 long position(java.sql.Clob searchstr, long start)
          Determines the character position at which the specified Clob object searchstr appears in this Clob object.
 long position(java.lang.String searchstr, long start)
          Determines the character position at which the specified substring searchstr appears in the SQL CLOB value represented by this Clob object.
 java.io.OutputStream setAsciiStream(long pos)
           
 java.io.Writer setCharacterStream(long pos)
           
 int setString(long pos, java.lang.String str)
           
 int setString(long pos, java.lang.String str, int offset, int len)
           
 java.lang.String toString()
          Returns a String that is a coma delimited list of up to the first 5 and last 5 chars of the Clob.
 void truncate(long len)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MAX_SIZE

public static final int DEFAULT_MAX_SIZE
See Also:
Constant Field Values
Constructor Detail

ClobImpl

public ClobImpl(java.sql.Clob clob)
         throws java.sql.SQLException
Creates a MMClob object by using the CharacterStream of the Clob argument.

Parameters:
clob - the Clob object to get the characters from.
Throws:
java.sql.SQLException

ClobImpl

public ClobImpl(char[] originalData)
Creates a MMClob object by copying the chars in originalData

Parameters:
originalData - the array of chars to copy into this MMClob object.

ClobImpl

public ClobImpl(java.io.InputStream in,
                java.nio.charset.Charset charSet,
                int length)
         throws java.sql.SQLException
Throws:
java.sql.SQLException

ClobImpl

public ClobImpl(java.io.Reader reader,
                int length)
         throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

getAsciiStream

public java.io.InputStream getAsciiStream()
                                   throws java.sql.SQLException
Gets the CLOB value designated by this Clob object as a stream of Ascii bytes.

Specified by:
getAsciiStream in interface java.sql.Clob
Returns:
an ascii stream containing the CLOB data
Throws:
java.sql.SQLException - if there is an error accessing the CLOB value

getCharacterStream

public java.io.Reader getCharacterStream()
                                  throws java.sql.SQLException
Gets the CLOB value designated by this Clob object as a Unicode stream.

Specified by:
getCharacterStream in interface java.sql.Clob
Returns:
a Unicode stream containing the CLOB data
Throws:
java.sql.SQLException - if there is an error accessing the CLOB value

getSubString

public java.lang.String getSubString(long pos,
                                     int length)
                              throws java.sql.SQLException
Returns a copy of the specified substring in the CLOB value designated by this Clob object. The substring begins at position pos and has up to length consecutive characters.

Specified by:
getSubString in interface java.sql.Clob
Parameters:
pos - the first character of the substring to be extracted. The first character is at position 1.
length - the number of consecutive characters to be copied
Returns:
a String that is the specified substring in the CLOB value designated by this Clob object
Throws:
java.sql.SQLException - if there is an error accessing the CLOB

length

public long length()
            throws java.sql.SQLException
Returns the number of characters in the CLOB value designated by this Clob object.

Specified by:
length in interface java.sql.Clob
Returns:
length of the CLOB in characters
Throws:
java.sql.SQLException - if there is an error accessing the length of the CLOB

position

public long position(java.sql.Clob searchstr,
                     long start)
              throws java.sql.SQLException
Determines the character position at which the specified Clob object searchstr appears in this Clob object. The search begins at position start.

Specified by:
position in interface java.sql.Clob
Parameters:
searchstr - the Clob object for which to search
start - the position at which to begin searching; the first position is 1
Returns:
the position at which the Clob object appears, else -1; the first position is 1
Throws:
java.sql.SQLException - if there is an error accessing the CLOB value

position

public long position(java.lang.String searchstr,
                     long start)
              throws java.sql.SQLException
Determines the character position at which the specified substring searchstr appears in the SQL CLOB value represented by this Clob object. The search begins at position start.

Specified by:
position in interface java.sql.Clob
Parameters:
searchstr - the substring for which to search
start - the position at which to begin searching; the first position is 1
Returns:
the position at which the substring appears, else -1; the first position is 1
Throws:
java.sql.SQLException - if there is an error accessing the CLOB value

equals

public boolean equals(java.lang.Object obj)
Compares two MMClob objects for equality.

Overrides:
equals in class java.lang.Object
Returns:
True if equal
See Also:
Object.equals(Object)

toString

public java.lang.String toString()
Returns a String that is a coma delimited list of up to the first 5 and last 5 chars of the Clob.

Overrides:
toString in class java.lang.Object
Returns:
the String object convenient for displaying this Clob object

setString

public int setString(long pos,
                     java.lang.String str)
              throws java.sql.SQLException
Specified by:
setString in interface java.sql.Clob
Throws:
java.sql.SQLException
See Also:
Clob.setString(long, java.lang.String)

setString

public int setString(long pos,
                     java.lang.String str,
                     int offset,
                     int len)
              throws java.sql.SQLException
Specified by:
setString in interface java.sql.Clob
Throws:
java.sql.SQLException
See Also:
Clob.setString(long, java.lang.String, int, int)

setAsciiStream

public java.io.OutputStream setAsciiStream(long pos)
                                    throws java.sql.SQLException
Specified by:
setAsciiStream in interface java.sql.Clob
Throws:
java.sql.SQLException
See Also:
Clob.setAsciiStream(long)

setCharacterStream

public java.io.Writer setCharacterStream(long pos)
                                  throws java.sql.SQLException
Specified by:
setCharacterStream in interface java.sql.Clob
Throws:
java.sql.SQLException
See Also:
Clob.setCharacterStream(long)

truncate

public void truncate(long len)
              throws java.sql.SQLException
Specified by:
truncate in interface java.sql.Clob
Throws:
java.sql.SQLException
See Also:
Clob.truncate(long)

free

public void free()
          throws java.sql.SQLException
Specified by:
free in interface java.sql.Clob
Throws:
java.sql.SQLException

getCharacterStream

public java.io.Reader getCharacterStream(long arg0,
                                         long arg1)
                                  throws java.sql.SQLException
Specified by:
getCharacterStream in interface java.sql.Clob
Throws:
java.sql.SQLException


Copyright © 2009. All Rights Reserved.