de.mguennewig.pobjects
Class PObjClob

java.lang.Object
  extended by de.mguennewig.pobjects.PObjClob
All Implemented Interfaces:
java.sql.Clob

public class PObjClob
extends java.lang.Object
implements java.sql.Clob

This class provides a portable way to create a CLOB.

NOTE: This class is only suitable to create a CLOB to put data into the database. You will get back a database specific CLOB when reading.

Author:
Michael Günnewig

Field Summary
static java.sql.Clob EMPTY_CLOB
          An empty unmodifiable CLOB.
 
Constructor Summary
PObjClob()
          Creates a new empty CLOB.
PObjClob(java.io.File file)
          Creates a new CLOB that uses the specified file for the data.
PObjClob(java.lang.String s)
          Creates a new CLOC for the given string.
 
Method Summary
 void free()
           
 java.io.InputStream getAsciiStream()
          Retrieves the CLOB value designated by this Clob object as an ASCII stream.
 java.io.Reader getCharacterStream()
          Retrieves the CLOB value designated by this Clob object as a Reader object (or as a stream of characters).
 java.io.Reader getCharacterStream(long pos, long length)
           
 java.lang.String getSubString(long pos, int length)
          Retrieves a copy of the specified substring in the CLOB value designated by this Clob object.
 long length()
          Retrieves the number of characters in 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 appears in this Clob object.
 long position(java.lang.String searchstr, long start)
          Retrieves 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)
          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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CLOB

public static final java.sql.Clob EMPTY_CLOB
An empty unmodifiable CLOB.

Constructor Detail

PObjClob

public PObjClob()
Creates a new empty CLOB.


PObjClob

public PObjClob(java.lang.String s)
Creates a new CLOC for the given string.


PObjClob

public PObjClob(java.io.File file)
Creates a new CLOB that uses the specified file for the data.

Method Detail

getAsciiStream

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

Specified by:
getAsciiStream in interface java.sql.Clob
Throws:
java.sql.SQLException

getCharacterStream

public java.io.Reader getCharacterStream()
                                  throws java.sql.SQLException
Retrieves the CLOB value designated by this Clob object as a Reader object (or as a stream of characters).

Specified by:
getCharacterStream in interface java.sql.Clob
Throws:
java.sql.SQLException

getSubString

public java.lang.String getSubString(long pos,
                                     int length)
                              throws java.sql.SQLException
Retrieves a copy of the specified substring in the CLOB value designated by this Clob object.

Specified by:
getSubString in interface java.sql.Clob
Throws:
java.sql.SQLException

length

public long length()
Retrieves the number of characters in the CLOB value designated by this Clob object.

Specified by:
length in interface java.sql.Clob

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 appears in this Clob object.

Specified by:
position in interface java.sql.Clob
Throws:
java.sql.SQLException
See Also:
position(String,long), getSubString(long,int)

position

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

Specified by:
position in interface java.sql.Clob
Throws:
java.lang.UnsupportedOperationException
java.sql.SQLException

setAsciiStream

public 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.

Specified by:
setAsciiStream in interface java.sql.Clob
Throws:
java.lang.UnsupportedOperationException

setCharacterStream

public 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.

Specified by:
setCharacterStream in interface java.sql.Clob
Throws:
java.lang.UnsupportedOperationException

setString

public final 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.

Specified by:
setString in interface java.sql.Clob
See Also:
setString(long,String,int,int)

setString

public 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.

Specified by:
setString in interface java.sql.Clob
Throws:
java.lang.UnsupportedOperationException

truncate

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

Specified by:
truncate in interface java.sql.Clob
Throws:
java.lang.UnsupportedOperationException

free

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

getCharacterStream

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