You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2007/06/14 14:44:32 UTC
svn commit: r547236 - in
/db/derby/code/trunk/java/client/org/apache/derby/client/am:
BlobLocatorInputStream.java BlobLocatorOutputStream.java Clob.java
ClobLocatorInputStream.java ClobLocatorReader.java
Author: kahatlen
Date: Thu Jun 14 05:44:31 2007
New Revision: 547236
URL: http://svn.apache.org/viewvc?view=rev&rev=547236
Log:
DERBY-2604: Implement Clob support for locators
Minor clean-ups. Contributed by V. Narayanan.
Modified:
db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorInputStream.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorOutputStream.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorInputStream.java
db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorReader.java
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorInputStream.java?view=diff&rev=547236&r1=547235&r2=547236
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorInputStream.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorInputStream.java Thu Jun 14 05:44:31 2007
@@ -161,12 +161,12 @@
/**
* Connection used to read Blob from server.
*/
- private Connection connection;
+ private final Connection connection;
/**
* The Blob to be accessed.
*/
- private Blob blob;
+ private final Blob blob;
/**
* Current position in the underlying Blob.
@@ -176,6 +176,7 @@
/**
* Position in Blob where to stop reading.
+ * maxPos starts counting from 1.
*/
- private long maxPos;
+ private final long maxPos;
}
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorOutputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorOutputStream.java?view=diff&rev=547236&r1=547235&r2=547236
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorOutputStream.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/BlobLocatorOutputStream.java Thu Jun 14 05:44:31 2007
@@ -135,12 +135,12 @@
/**
* Connection used to read Blob from server.
*/
- private Connection connection;
+ private final Connection connection;
/**
* The Blob to be accessed.
*/
- private Blob blob;
+ private final Blob blob;
/**
* Current position in the underlying Blob.
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java?view=diff&rev=547236&r1=547235&r2=547236
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Clob.java Thu Jun 14 05:44:31 2007
@@ -539,7 +539,7 @@
}
// if the searchstr is longer than the source, no match
- int index;
+ long index;
try {
if (searchstr.length() > sqlLength()) {
return -1;
@@ -550,7 +550,7 @@
//Locator support is available. Hence call
//CLOBGETPOSITIONFROMLOCATOR to determine the position
//of the given Clob inside the LOB.
- index = (int)agent_.connection_.locatorProcedureCall()
+ index = agent_.connection_.locatorProcedureCall()
.clobGetPositionFromLocator(locator_,
((Clob)searchstr).getLocator(),
start);
@@ -559,18 +559,16 @@
index = string_.indexOf(searchstr.getSubString(1L,
(int) searchstr.length()),
(int) start - 1);
+ //increase the index by one since String positions are
+ //0-based and Clob positions are 1-based
+ if (index != -1) {
+ index++;
+ }
}
} catch (java.sql.SQLException e) {
throw new SqlException(e);
}
- //When the LOB is locator enabled then
- //the stored procedure call returns the
- //correct position. There is no need
- //to increment by 1
- if (index != -1 && !isLocator()) {
- index++; // api index starts at 1
- }
- return (long) index;
+ return index;
}
//---------------------------- jdbc 3.0 -----------------------------------
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorInputStream.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorInputStream.java?view=diff&rev=547236&r1=547235&r2=547236
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorInputStream.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorInputStream.java Thu Jun 14 05:44:31 2007
@@ -64,8 +64,9 @@
/**
* Position in Clob where to stop reading.
+ * maxPos starts counting from 1.
*/
- private long maxPos;
+ private final long maxPos;
/**
* Create an <code>InputStream</code> for reading the
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorReader.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorReader.java?view=diff&rev=547236&r1=547235&r2=547236
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorReader.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/ClobLocatorReader.java Thu Jun 14 05:44:31 2007
@@ -55,8 +55,9 @@
/**
* Position in Clob where to stop reading.
+ * maxPos starts counting from 1.
*/
- private long maxPos;
+ private final long maxPos;
/**
* Stores the information to whether this Reader has been
@@ -100,7 +101,12 @@
*/
public ClobLocatorReader(Connection connection, Clob clob,
long pos, long len) throws SqlException {
- this(connection, clob);
+ if (SanityManager.DEBUG) {
+ SanityManager.ASSERT(clob.isLocator());
+ }
+
+ this.connection = connection;
+ this.clob = clob;
this.currentPos = pos;
this.maxPos = Math.min(clob.sqlLength(), pos + len - 1);
}