harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r520401 - in /harmony/enhanced/classlib/trunk/modules/sql/src: main/java/javax/sql/rowset/serial/SerialClob.java test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
Date Tue, 20 Mar 2007 14:19:57 GMT
Author: ayza
Date: Tue Mar 20 07:19:56 2007
New Revision: 520401

URL: http://svn.apache.org/viewvc?view=rev&rev=520401
Log:
Applying patch from HARMONY-3438 ([classlib][sql] Implementation for SerialClob.position(Clob,
long))

Modified:
    harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java?view=diff&rev=520401&r1=520400&r2=520401
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/rowset/serial/SerialClob.java
Tue Mar 20 07:19:56 2007
@@ -107,17 +107,18 @@
         return new String(buf, (int) (pos - 1), length);
     }
 
-    public long position(Clob searchstr, long start) throws SerialException,
-            SQLException, NotImplementedException {
-        throw new NotImplementedException();
+    public long position(Clob searchClob, long start) throws SerialException,
+            SQLException {
+        String searchString = searchClob.getSubString(1, (int)searchClob.length());
+        return position(searchString, start);
     }
 
-    public long position(String searchstr, long start) throws SerialException,
+    public long position(String searchString, long start) throws SerialException,
             SQLException {
-        if (start < 1 || len - (start - 1) < searchstr.length()) {
+        if (start < 1 || len - (start - 1) < searchString.length()) {
             return -1;
         }
-        char[] pattern = searchstr.toCharArray();
+        char[] pattern = searchString.toCharArray();
         for (int i = (int) start - 1; i < len; i++) {
             if (match(buf, i, pattern)) {
                 return i + 1;

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java?view=diff&rev=520401&r1=520400&r2=520401
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
Tue Mar 20 07:19:56 2007
@@ -146,14 +146,39 @@
 
     }
 
-    public void testPositionLClobJ() {
-        // TODO: Not yet implemented
+    public void testPositionLClobJ() throws Exception {
+        SerialClob serialClob = new SerialClob("helloo".toCharArray());
+        SerialClob searchClob = new SerialClob("llo".toCharArray());
+        long pos = serialClob.position(searchClob, 1);
+        assertEquals(3, pos);
+        
+        pos = serialClob.position(searchClob, 3);
+        assertEquals(3, pos);
+        
+        searchClob = new SerialClob("o".toCharArray());
+        pos = serialClob.position(searchClob, 6);
+        assertEquals(6, pos);
+        
+        searchClob = new SerialClob("ooooooo".toCharArray());
+        pos = serialClob.position(searchClob, 1);
+        assertEquals(-1, pos);
+        
+        searchClob = new SerialClob("llo".toCharArray());
+        pos = serialClob.position(searchClob, 4);
+        assertEquals(-1, pos);
+        
+        pos = serialClob.position(searchClob, 0);
+        assertEquals(-1, pos);
+        
+        pos = serialClob.position(searchClob, -1);
+        assertEquals(-1, pos);
+        
+        pos = serialClob.position(searchClob, 10);
+        assertEquals(-1, pos);
     }
 
     public void testPositionLStringJ() throws Exception {
-        String s = "helloo";
-        char[] buf = s.toCharArray();
-        SerialClob serialClob = new SerialClob(buf);
+        SerialClob serialClob = new SerialClob("helloo".toCharArray());
         
         long pos = serialClob.position("llo", 1);
         assertEquals(3, pos);



Mime
View raw message