org.objectweb.cjdbc.driver
Class Clob

java.lang.Object
  extended byorg.objectweb.cjdbc.driver.Clob
All Implemented Interfaces:
java.sql.Clob, java.io.Serializable

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

The representation (mapping) in the Java TM programming language of an SQL CLOB value. An SQL CLOB is a built-in type that stores a Character Large Object as a column value in a row of a database table. By default drivers implement Clob using an SQL locator(CLOB), which means that a Clob object contains a logical pointer to the SQL CLOB data rather than the data itself. A Clob object is valid for the duration of the transaction in which is was created.

Methods in the interfaces DriverResultSet,CallableStatement, and PreparedStatement, such as getClob and setClob allow a programmer to access an SQL CLOB value. The Clob interface provides methods for getting the length of an SQL CLOB (Character Large Object) value, for materializing a CLOB value on the client, and for determining the position of a pattern of bytes within a CLOB value. In addition, this interface has methods for updating a CLOB value.

Since:
JDK 1.2
Author:
Nicolas Modrzyk , Emmanuel Cecchet
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
           
private  java.lang.String stringData
          The data represented as a string of this CLOB
 
Constructor Summary
Clob(java.lang.String data)
          Creates a new Clob instance.
 
Method Summary
 java.io.InputStream getAsciiStream()
          Retrieves the CLOB value designated by this Clob instance as a stream.
 java.io.Reader getCharacterStream()
          Materializes the CLOB value designated by this object as a stream of Unicode character.
 java.lang.String getSubString(long pos, int length)
          Returns a copy of the portion of the CLOB value represented by this CLOB object that starts at position position and has ip to length consecutive characters.
 long length()
          Returns the size of the CLOB value designated by this Clob object
 long position(java.sql.Clob searchstr, long start)
          Retrieves the character position at which the specified Clob object searchstr begins within the CLOB value that this Clob object represents.
 long position(java.lang.String searchstr, long start)
          Retrieves the character position at which the specified string searchstr begins within the CLOB value that this Clob object represents.
 java.io.OutputStream setAsciiStream(long pos)
          Retrieves a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, starting at position pos.
 java.io.Writer setCharacterStream(long pos)
          Retrieves a stream to be used to write a stream of Unicode characters to the CLOB value that this Clob object represents, at position pos.
 int setString(long pos, java.lang.String str)
          Writes the given Java String to the CLOB value that this Clob object designates at the position pos.
 int setString(long pos, java.lang.String str, int offset, int len)
          Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents.
 void truncate(long len)
          Truncates the CLOB value that this Clob designates to have a length of len characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

stringData

private java.lang.String stringData
The data represented as a string of this CLOB

Constructor Detail

Clob

public Clob(java.lang.String data)
Creates a new Clob instance.

Parameters:
data - a String of character data
Method Detail

length

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

Specified by:
length in interface java.sql.Clob
Returns:
length of the CLOB value that this clob represents
Throws:
java.sql.SQLException - if there is an error accessing the length of the CLOB
Since:
JDK 1.2

getAsciiStream

public java.io.InputStream getAsciiStream()
                                   throws java.sql.SQLException
Retrieves the CLOB value designated by this Clob instance as a stream.

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

getCharacterStream

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

Specified by:
getCharacterStream in interface java.sql.Clob
Returns:
A reader object with all the data in the CLOB value designated by this clob object as unicode characters.
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 portion of the CLOB value represented by this CLOB object that starts at position position and has ip to length consecutive characters.

Specified by:
getSubString in interface java.sql.Clob
Parameters:
pos - the position where to get the substring from
length - the length of the substring
Returns:
the substring
Throws:
java.sql.SQLException - if there is an error accessing the CLOB
Since:
JDK 1.2

position

public long position(java.lang.String searchstr,
                     long start)
              throws java.sql.SQLException
Retrieves the character position at which the specified string searchstr begins within the CLOB value that this Clob object represents. The search for searchstr begins at position start.

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

position

public long position(java.sql.Clob searchstr,
                     long start)
              throws java.sql.SQLException
Retrieves the character position at which the specified Clob object searchstr begins within the CLOB value that this Clob object represents. The search for searchstr begins at position start.

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

setAsciiStream

public java.io.OutputStream setAsciiStream(long pos)
                                    throws java.sql.SQLException
Retrieves a stream to be used to write Ascii characters to the CLOB value that this Clob object represents, starting at position pos.

Specified by:
setAsciiStream in interface java.sql.Clob
Parameters:
pos - the position where to start the stream
Returns:
the ascii outputstream to this clob object
Throws:
java.sql.SQLException - if there is an error accessing the clob

setCharacterStream

public java.io.Writer setCharacterStream(long pos)
                                  throws java.sql.SQLException
Retrieves a stream to be used to write a stream of Unicode characters to the CLOB value that this Clob object represents, at position pos.

Specified by:
setCharacterStream in interface java.sql.Clob
Parameters:
pos - the position where to start the writer
Returns:
the writer to this clob object
Throws:
java.sql.SQLException - if there is an error accessing the clob

setString

public int setString(long pos,
                     java.lang.String str)
              throws java.sql.SQLException
Writes the given Java String to the CLOB value that this Clob object designates at the position pos.

Specified by:
setString in interface java.sql.Clob
Parameters:
pos - the position where to set the string
str - string to insert in the clob
Returns:
return value
Throws:
java.sql.SQLException - if there is an error accessing the clob

setString

public int setString(long pos,
                     java.lang.String str,
                     int offset,
                     int len)
              throws java.sql.SQLException
Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents.

Specified by:
setString in interface java.sql.Clob
Parameters:
pos - the position
str - the string
offset - the offset
len - the length
Returns:
return value
Throws:
java.sql.SQLException - if there is an error accessing the clob

truncate

public void truncate(long len)
              throws java.sql.SQLException
Truncates the CLOB value that this Clob designates to have a length of len characters.

Specified by:
truncate in interface java.sql.Clob
Parameters:
len - the length
Throws:
java.sql.SQLException - if there is an error accessing the clob


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.