railo.runtime.type.sql
Class ClobImpl

java.lang.Object
  extended by railo.runtime.type.sql.ClobImpl
All Implemented Interfaces:
Serializable, Clob

public final class ClobImpl
extends Object
implements Clob, 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.

See Also:
Serialized Form

Method Summary
 void free()
           
 InputStream getAsciiStream()
          Retrieves the CLOB value designated by this Clob instance as a stream.
 Reader getCharacterStream()
          Materializes the CLOB value designated by this object as a stream of Unicode character.
 Reader getCharacterStream(long pos, long len)
           
 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(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(String searchstr, long start)
          Retrieves the character position at which the specified string searchstr begins within the CLOB value that this Clob object represents.
 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.
 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, String str)
          Writes the given Java String to the CLOB value that this Clob object designates at the position pos.
 int setString(long pos, String str, int offset, int len)
          Writes len characters of str, starting at character offset, to the CLOB value that this Clob represents.
static Clob toClob(Object value)
          cast given value to a clob
static Clob toClob(String value)
           
 String toString()
           
 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

toClob

public static Clob toClob(Object value)
                   throws PageException
cast given value to a clob

Parameters:
value -
Returns:
clob
Throws:
PageException

toClob

public static Clob toClob(String value)

length

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

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

getAsciiStream

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

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

getCharacterStream

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

Specified by:
getCharacterStream in interface Clob
Returns:
A reader object with all the data in the CLOB value designated by this clob object as unicode characters.
Throws:
SQLException - if there is an error accessing the CLOB value

getCharacterStream

public Reader getCharacterStream(long pos,
                                 long len)
Specified by:
getCharacterStream in interface Clob

getSubString

public String getSubString(long pos,
                           int length)
                    throws 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 Clob
Parameters:
pos - the position where to get the substring from
length - the length of the substring
Returns:
the substring
Throws:
SQLException - if there is an error accessing the CLOB

position

public long position(String searchstr,
                     long start)
              throws 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 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:
SQLException - if there is an error accessing the CLOB

position

public long position(Clob searchstr,
                     long start)
              throws 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 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:
SQLException - if there is an error accessing the CLOB

setAsciiStream

public OutputStream setAsciiStream(long pos)
                            throws 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 Clob
Parameters:
pos - the position where to start the stream
Returns:
the ascii outputstream to this clob object
Throws:
SQLException - if there is an error accessing the clob

setCharacterStream

public Writer setCharacterStream(long pos)
                          throws 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 Clob
Parameters:
pos - the position where to start the writer
Returns:
the writer to this clob object
Throws:
SQLException - if there is an error accessing the clob

setString

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

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

setString

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

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

truncate

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

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

toString

public String toString()
Overrides:
toString in class Object

free

public void free()
Specified by:
free in interface Clob


Copyright © 2012 Railo