- All Implemented Interfaces:
- Serializable,- Cloneable,- Clob
CLOB value.
 
 The SerialClob class provides a constructor for creating
 an instance from a Clob object.  Note that the Clob
 object should have brought the SQL CLOB value's data over
 to the client before a SerialClob object
 is constructed from it.  The data of an SQL CLOB value can
 be materialized on the client as a stream of Unicode characters.
 
 SerialClob methods make it possible to get a substring
 from a SerialClob object or to locate the start of
 a pattern of characters.
 
Thread safety
A SerialClob is not safe for use by multiple concurrent threads. If a SerialClob is to be used by more than one thread then access to the SerialClob should be controlled by appropriate synchronization.
- Since:
- 1.5
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionSerialClob(char[] ch) Constructs aSerialClobobject that is a serialized version of the givenchararray.SerialClob(Clob clob) Constructs aSerialClobobject that is a serialized version of the givenClobobject.
- 
Method SummaryModifier and TypeMethodDescriptionclone()Returns a clone of thisSerialClob.booleanCompares this SerialClob to the specified object.voidfree()This method frees theSerialClobobject and releases the resources that it holds.Retrieves theCLOBvalue designated by thisSerialClobobject as an ascii stream.Returns thisSerialClobobject's data as a stream of Unicode characters.getCharacterStream(long pos, long length) Returns aReaderobject that contains a partialSerialClobvalue, starting with the character specified by pos, which is length characters in length.getSubString(long pos, int length) Returns a copy of the substring contained in thisSerialClobobject, starting at the given position and continuing for the specified number or characters.inthashCode()Returns a hash code for thisSerialClob.longlength()Retrieves the number of characters in thisSerialClobobject's array of characters.longReturns the position in thisSerialClobobject where the givenStringobject begins, starting the search at the specified position.longReturns the position in thisSerialClobobject where the givenClobsignature begins, starting the search at the specified position.setAsciiStream(long pos) Retrieves a stream to be used to write Ascii characters to theCLOBvalue that thisSerialClobobject represents, starting at positionpos.setCharacterStream(long pos) Retrieves a stream to be used to write a stream of Unicode characters to theCLOBvalue that thisSerialClobobject represents, at positionpos.intWrites the given JavaStringto theCLOBvalue that thisSerialClobobject represents, at the positionpos.intWriteslencharacters ofstr, starting at characteroffset, to theCLOBvalue that thisClobrepresents.voidtruncate(long length) Truncates theCLOBvalue that thisSerialClobobject represents so that it has a length oflencharacters.
- 
Constructor Details- 
SerialClobConstructs aSerialClobobject that is a serialized version of the givenchararray.The new SerialClobobject is initialized with the data from thechararray, thus allowing disconnectedRowSetobjects to establish a serializedClobobject without touching the data source.- Parameters:
- ch- the char array representing the- Clobobject to be serialized
- Throws:
- SerialException- if an error occurs during serialization
- SQLException- if a SQL error occurs
 
- 
SerialClobConstructs aSerialClobobject that is a serialized version of the givenClobobject.The new SerialClobobject is initialized with the data from theClobobject; therefore, theClobobject should have previously brought the SQLCLOBvalue's data over to the client from the database. Otherwise, the newSerialClobobject object will contain no data.Note: The Clobobject supplied to this constructor must return non-null for both theClob.getCharacterStream()andClob.getAsciiStreammethods. ThisSerialClobconstructor cannot serialize aClobobject in this instance and will throw anSQLExceptionobject.- Parameters:
- clob- the- Clobobject from which this- SerialClobobject is to be constructed; cannot be null
- Throws:
- SerialException- if an error occurs during serialization
- SQLException- if a SQL error occurs in capturing the CLOB; if the- Clobobject is a null; or if either of the- Clob.getCharacterStream()and- Clob.getAsciiStream()methods on the- Clobreturns a null
- See Also:
 
 
- 
- 
Method Details- 
lengthRetrieves the number of characters in thisSerialClobobject's array of characters.- Specified by:
- lengthin interface- Clob
- Returns:
- a longindicating the length in characters of thisSerialClobobject's array of character
- Throws:
- SerialException- if an error occurs; if- freehad previously been called on this object
 
- 
getCharacterStreamReturns thisSerialClobobject's data as a stream of Unicode characters. Unlike the related method,getAsciiStream, a stream is produced regardless of whether theSerialClobobject was created with aClobobject or achararray.- Specified by:
- getCharacterStreamin interface- Clob
- Returns:
- a java.io.Readerobject containing thisSerialClobobject's data
- Throws:
- SerialException- if an error occurs; if- freehad previously been called on this object
- See Also:
 
- 
getAsciiStreamRetrieves theCLOBvalue designated by thisSerialClobobject as an ascii stream. This method forwards thegetAsciiStreamcall to the underlyingClobobject in the event that thisSerialClobobject is instantiated with aClobobject. If thisSerialClobobject is instantiated with achararray, aSerialExceptionobject is thrown.- Specified by:
- getAsciiStreamin interface- Clob
- Returns:
- a java.io.InputStreamobject containing thisSerialClobobject's data
- Throws:
- SerialException- if this- SerialClobobject was not instantiated with a- Clobobject; if- freehad previously been called on this object
- SQLException- if there is an error accessing the- CLOBvalue represented by the- Clobobject that was used to create this- SerialClobobject
- See Also:
 
- 
getSubStringReturns a copy of the substring contained in thisSerialClobobject, starting at the given position and continuing for the specified number or characters.- Specified by:
- getSubStringin interface- Clob
- Parameters:
- pos- the position of the first character in the substring to be copied; the first character of the- SerialClobobject is at position- 1; must not be less than- 1, and the sum of the starting position and the length of the substring must be less than the length of this- SerialClobobject
- length- the number of characters in the substring to be returned; must not be greater than the length of this- SerialClobobject, and the sum of the starting position and the length of the substring must be less than the length of this- SerialClobobject
- Returns:
- a Stringobject containing a substring of thisSerialClobobject beginning at the given position and containing the specified number of consecutive characters
- Throws:
- SerialException- if either of the arguments is out of bounds; if- freehad previously been called on this object
 
- 
positionReturns the position in thisSerialClobobject where the givenStringobject begins, starting the search at the specified position. This method returns-1if the pattern is not found.- Specified by:
- positionin interface- Clob
- Parameters:
- searchStr- the- Stringobject for which to search
- start- the position in this- SerialClobobject at which to start the search; the first position is- 1; must not be less than- 1nor greater than the length of this- SerialClobobject
- Returns:
- the position at which the given Stringobject begins, starting the search at the specified position;-1if the givenStringobject is not found or the starting position is out of bounds; position numbering for the return value starts at1
- Throws:
- SerialException- if the- freemethod had been previously called on this object
- SQLException- if there is an error accessing the Clob value from the database.
 
- 
positionReturns the position in thisSerialClobobject where the givenClobsignature begins, starting the search at the specified position. This method returns-1if the pattern is not found.- Specified by:
- positionin interface- Clob
- Parameters:
- searchStr- the- Clobobject for which to search
- start- the position in this- SerialClobobject at which to begin the search; the first position is- 1; must not be less than- 1nor greater than the length of this- SerialClobobject
- Returns:
- the position at which the given Clobobject begins in thisSerialClobobject, at or after the specified starting position
- Throws:
- SerialException- if an error occurs locating the Clob signature; if the- freemethod had been previously called on this object
- SQLException- if there is an error accessing the Clob value from the database
 
- 
setStringWrites the given JavaStringto theCLOBvalue that thisSerialClobobject represents, at the positionpos.- Specified by:
- setStringin interface- Clob
- Parameters:
- pos- the position at which to start writing to the- CLOBvalue that this- SerialClobobject represents; the first position is- 1; must not be less than- 1nor greater than the length of this- SerialClobobject
- str- the string to be written to the- CLOBvalue that this- SerialClobobject represents
- Returns:
- the number of characters written
- Throws:
- SerialException- if there is an error accessing the- CLOBvalue; if an invalid position is set; if an invalid offset value is set; if number of bytes to be written is greater than the- SerialCloblength; or the combined values of the length and offset is greater than the Clob buffer; if the- freemethod had been previously called on this object
 
- 
setStringWriteslencharacters ofstr, starting at characteroffset, to theCLOBvalue that thisClobrepresents.- Specified by:
- setStringin interface- Clob
- Parameters:
- pos- the position at which to start writing to the- CLOBvalue that this- SerialClobobject represents; the first position is- 1; must not be less than- 1nor greater than the length of this- SerialClobobject
- str- the string to be written to the- CLOBvalue that this- Clobobject represents
- offset- the offset into- strto start reading the characters to be written
- length- the number of characters to be written
- Returns:
- the number of characters written
- Throws:
- SerialException- if there is an error accessing the- CLOBvalue; if an invalid position is set; if an invalid offset value is set; if number of bytes to be written is greater than the- SerialCloblength; or the combined values of the length and offset is greater than the Clob buffer; if the- freemethod had been previously called on this object
 
- 
setAsciiStreamRetrieves a stream to be used to write Ascii characters to theCLOBvalue that thisSerialClobobject represents, starting at positionpos. This method forwards thesetAsciiStream()call to the underlyingClobobject in the event that thisSerialClobobject is instantiated with aClobobject. If thisSerialClobobject is instantiated with achararray, aSerialExceptionobject is thrown.- Specified by:
- setAsciiStreamin interface- Clob
- Parameters:
- pos- the position at which to start writing to the- CLOBobject
- Returns:
- the stream to which ASCII encoded characters can be written
- Throws:
- SerialException- if SerialClob is not instantiated with a Clob object; if the- freemethod had been previously called on this object
- SQLException- if there is an error accessing the- CLOBvalue
- See Also:
 
- 
setCharacterStreamRetrieves a stream to be used to write a stream of Unicode characters to theCLOBvalue that thisSerialClobobject represents, at positionpos. This method forwards thesetCharacterStream()call to the underlyingClobobject in the event that thisSerialClobobject is instantiated with aClobobject. If thisSerialClobobject is instantiated with achararray, aSerialExceptionis thrown.- Specified by:
- setCharacterStreamin interface- Clob
- Parameters:
- pos- the position at which to start writing to the- CLOBvalue
- Returns:
- a stream to which Unicode encoded characters can be written
- Throws:
- SerialException- if the SerialClob is not instantiated with a Clob object; if the- freemethod had been previously called on this object
- SQLException- if there is an error accessing the- CLOBvalue
- See Also:
 
- 
truncateTruncates theCLOBvalue that thisSerialClobobject represents so that it has a length oflencharacters.Truncating a SerialClobobject to length 0 has the effect of clearing its contents.- Specified by:
- truncatein interface- Clob
- Parameters:
- length- the length, in bytes, to which the- CLOBvalue should be truncated
- Throws:
- SerialException- if there is an error accessing the- CLOBvalue; if the- freemethod had been previously called on this object
 
- 
getCharacterStreamReturns aReaderobject that contains a partialSerialClobvalue, starting with the character specified by pos, which is length characters in length.- Specified by:
- getCharacterStreamin interface- Clob
- Parameters:
- pos- the offset to the first character of the partial value to be retrieved. The first character in the- SerialClobis at position 1.
- length- the length in characters of the partial value to be retrieved.
- Returns:
- Readerthrough which the partial- SerialClobvalue can be read.
- Throws:
- SQLException- if pos is less than 1 or if pos is greater than the number of characters in the- SerialClobor if pos + length is greater than the number of characters in the- SerialClob;
- SerialException- if the- freemethod had been previously called on this object
- Since:
- 1.6
 
- 
freeThis method frees theSerialClobobject and releases the resources that it holds. The object is invalid once thefreemethod is called.If freeis called multiple times, the subsequent calls tofreeare treated as a no-op.- Specified by:
- freein interface- Clob
- Throws:
- SQLException- if an error occurs releasing the Clob's resources
- Since:
- 1.6
 
- 
equalsCompares this SerialClob to the specified object. The result istrueif and only if the argument is notnulland is aSerialClobobject that represents the same sequence of characters as this object.
- 
hashCodepublic int hashCode()Returns a hash code for thisSerialClob.
- 
cloneReturns a clone of thisSerialClob. The copy will contain a reference to a clone of the internal character array, not a reference to the original internal character array of thisSerialClobobject. The underlyingClobobject will be set to null.
 
-