com.ibm.ims.xms
Class XMSMaterializer

java.lang.Object
  |
  +--com.ibm.ims.xms.XMSMaterializer
All Implemented Interfaces:
java.sql.Clob

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

Implements the CLOB interface, and is returned from a JDBC SELECT query.


Field Summary
protected  DLIConnection dliConnection
           
 byte[] kfba
           
protected  boolean open
           
 java.lang.String pcbAlias
           
 java.lang.String rootSegmentName
           
protected  boolean validate
           
protected  XMSGrammarPool xmsGrammarPool
           
 
Constructor Summary
XMSMaterializer(byte[] kfba, java.lang.String rootSegmentName, java.lang.String pcbAlias, DLIConnection dliConnection, XMSGrammarPool xmsGrammarPool, boolean validate)
          Creates a XMSMaterializer object used for retrieval from a DLI database.
 
Method Summary
 void close()
          Closes the XMSMaterializer.
 java.io.InputStream getAsciiStream()
          Implements the Clob.getAsciiStream() method.
 java.io.Reader getCharacterStream()
          Implements the Clob.getCharacterStream() method.
 char[] getMaterializedCharArray()
          Used internally for cacheing the char array during SCROLL_INSENSITIVE ResultSets.
 java.lang.String getSubString(long pos, int length)
          Returns a String from pos of size length.
 long length()
          Implements the Clob.length() method.
 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)
          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

kfba

public byte[] kfba

rootSegmentName

public java.lang.String rootSegmentName

pcbAlias

public java.lang.String pcbAlias

validate

protected boolean validate

dliConnection

protected DLIConnection dliConnection

xmsGrammarPool

protected XMSGrammarPool xmsGrammarPool

open

protected boolean open
Constructor Detail

XMSMaterializer

public XMSMaterializer(byte[] kfba,
                       java.lang.String rootSegmentName,
                       java.lang.String pcbAlias,
                       DLIConnection dliConnection,
                       XMSGrammarPool xmsGrammarPool,
                       boolean validate)
Creates a XMSMaterializer object used for retrieval from a DLI database. XML Document starts at the specified segment with matching key feedback area, with rootSegmentName. The passed in pcbAlias, and dliConnection are used to retrieve xml Document.
Method Detail

length

public long length()
            throws java.sql.SQLException
Implements the Clob.length() method. Initializes and consumes bytes until it discovers the length. All Readers and InputStreams are closed.
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

getSubString

public java.lang.String getSubString(long pos,
                                     int length)
                              throws java.sql.SQLException
Returns a String from pos of size length. All Readers and InputStreams are closed.
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

getCharacterStream

public java.io.Reader getCharacterStream()
                                  throws java.sql.SQLException
Implements the Clob.getCharacterStream() method. XML document is materialized as the stream is read.
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

getAsciiStream

public java.io.InputStream getAsciiStream()
                                   throws java.sql.SQLException
Implements the Clob.getAsciiStream() method. XML document is materialized as the steam is read.
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

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. All Readers and InputStreams are closed.
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

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

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.
Parameters:
pos - the position at which to start writing to the CLOB value that this Clob object represents
str - the string to be written to the CLOB value that this Clob designates
Returns:
the number of characters written
Throws:
java.sql.SQLException - if there is an error accessing the CLOB value
Since:
1.4

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.
Parameters:
pos - the position at which to start writing to this CLOB object
str - the string to be written to the CLOB value that this Clob object represents
offset - the offset into str to start reading the characters to be written
len - the number of characters to be written
Returns:
the number of characters written
Throws:
java.sql.SQLException - if there is an error accessing the CLOB value
Since:
1.4

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.
Parameters:
pos - the position at which to start writing to this CLOB object
Returns:
the stream to which ASCII encoded characters can be written
Throws:
java.sql.SQLException - if there is an error accessing the CLOB value
Since:
1.4
See Also:
getAsciiStream()

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.
Parameters:
pos - the position at which to start writing to the CLOB value
Returns:
a stream to which Unicode encoded characters can be written
Throws:
java.sql.SQLException - if there is an error accessing the CLOB value
Since:
1.4
See Also:
getCharacterStream()

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.
Parameters:
len - the length, in bytes, to which the CLOB value should be truncated
Throws:
java.sql.SQLException - if there is an error accessing the CLOB value
Since:
1.4

getMaterializedCharArray

public char[] getMaterializedCharArray()
                                throws java.sql.SQLException
Used internally for cacheing the char array during SCROLL_INSENSITIVE ResultSets.

close

public void close()
Closes the XMSMaterializer. This means no new XML content can be created. A ResultSet should close it when either a next() call is made or the ResultSet itself is closed. Once closed a XMSMaterializer cannot be reopened.


(C) International Business Machines Corporation 2004. All rights reserved.