Methods Summary |
---|
public void | free()
throw new java.lang.UnsupportedOperationException("Not supported");
|
public java.io.InputStream | getAsciiStream()Retrieves the CLOB value designated by this SerialClob
object as an ascii stream. This method forwards the getAsciiStream
call to the underlying Clob object in the event that this
SerialClob object is instantiated with a Clob
object. If this SerialClob object is instantiated with
a char array, a SerialException object is thrown.
if (this.clob != null) {
return this.clob.getAsciiStream();
} else {
throw new SerialException("Unsupported operation. SerialClob cannot " +
"return a the CLOB value as an ascii stream, unless instantiated " +
"with a fully implemented Clob object.");
}
|
public java.io.Reader | getCharacterStream(long pos, long length)
throw new java.lang.UnsupportedOperationException("Not supported");
|
public java.io.Reader | getCharacterStream()Returns this SerialClob object's data as a stream
of Unicode characters. Unlike the related method, getAsciiStream ,
a stream is produced regardless of whether the SerialClob object
was created with a Clob object or a char array.
return (java.io.Reader) new CharArrayReader(buf);
|
public java.lang.String | getSubString(long pos, int length)Returns a copy of the substring contained in this
SerialClob object, starting at the given position
and continuing for the specified number or characters.
if (pos < 1 || pos > this.length()) {
throw new SerialException("Invalid position in BLOB object set");
}
if ((pos-1) + length > this.length()) {
throw new SerialException("Invalid position and substring length");
}
try {
return new String(buf, (int)pos - 1, length);
} catch (StringIndexOutOfBoundsException e) {
throw new SerialException("StringIndexOutOfBoundsException: " +
e.getMessage());
}
|
public long | length()Retrieves the number of characters in this SerialClob
object's array of characters.
return len;
|
public long | position(java.lang.String searchStr, long start)Returns the position in this SerialClob object
where the given String object begins, starting
the search at the specified position. This method returns
-1 if the pattern is not found.
if (start < 1 || start > len) {
return -1;
}
char pattern[] = searchStr.toCharArray();
int pos = (int)start-1;
int i = 0;
long patlen = pattern.length;
while (pos < len) {
if (pattern[i] == buf[pos]) {
if (i + 1 == patlen) {
return (pos + 1) - (patlen - 1);
}
i++; pos++; // increment pos, and i
} else if (pattern[i] != buf[pos]) {
pos++; // increment pos only
}
}
return -1; // not found
|
public long | position(java.sql.Clob searchStr, long start)Returns the position in this SerialClob object
where the given Clob signature begins, starting
the search at the specified position. This method returns
-1 if the pattern is not found.
return position(searchStr.getSubString(1,(int)searchStr.length()), start);
|
public java.io.OutputStream | setAsciiStream(long pos)Retrieves a stream to be used to write Ascii characters to the
CLOB value that this SerialClob object represents,
starting at position pos . This method forwards the
setAsciiStream() call to the underlying Clob object in
the event that this SerialClob object is instantiated with a
Clob object. If this SerialClob object is instantiated
with a char array, a SerialException object is thrown.
if (this.clob.setAsciiStream(pos) != null) {
return this.clob.setAsciiStream(pos);
} else {
throw new SerialException("Unsupported operation. SerialClob cannot " +
"return a writable ascii stream\n unless instantiated with a Clob object " +
"that has a setAsciiStream() implementation");
}
|
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 SerialClob object
represents, at position pos . This method forwards the
setCharacterStream() call to the underlying Clob
object in the event that this SerialClob object is instantiated with a
Clob object. If this SerialClob object is instantiated with
a char array, a SerialException is thrown.
if (this.clob.setCharacterStream(pos) != null) {
return this.clob.setCharacterStream(pos);
} else {
throw new SerialException("Unsupported operation. SerialClob cannot " +
"return a writable character stream\n unless instantiated with a Clob object " +
"that has a setCharacterStream implementation");
}
|
public int | setString(long pos, java.lang.String str, int offset, int length)Writes len characters of str , starting
at character offset , to the CLOB value
that this Clob represents.
String temp = str.substring(offset);
char cPattern[] = temp.toCharArray();
if (offset < 0 || offset > str.length()) {
throw new SerialException("Invalid offset in byte array set");
}
if (pos < 1 || pos > this.length()) {
throw new SerialException("Invalid position in BLOB object set");
}
if ((long)(length) > origLen) {
throw new SerialException("Buffer is not sufficient to hold the value");
}
if ((length + offset) > str.length()) {
// need check to ensure length + offset !> bytes.length
throw new SerialException("Invalid OffSet. Cannot have combined offset " +
" and length that is greater that the Blob buffer");
}
int i = 0;
pos--; //values in the array are at position one less
while ( i < length || (offset + i +1) < (str.length() - offset ) ) {
this.buf[(int)pos + i ] = cPattern[offset + i ];
i++;
}
return i;
|
public int | setString(long pos, java.lang.String str)Writes the given Java String to the CLOB
value that this SerialClob object represents, at the position
pos .
return (setString(pos, str, 0, str.length()));
|
public void | truncate(long length)Truncates the CLOB value that this SerialClob
object represents so that it has a length of len
characters.
Truncating a SerialClob object to length 0 has the effect of
clearing its contents.
if (length > len) {
throw new SerialException
("Length more than what can be truncated");
} else {
len = length;
// re-size the buffer
if (len == 0) {
buf = new char[] {};
} else {
buf = (this.getSubString(1, (int)len)).toCharArray();
}
}
|